Because if it walks like a duck and quacks like a duck, you don't need to DECLARE that it's a duck.
pywrong is a Python "linter" that enforces duck typing by finding and shaming all type hints in your code.
__
___( o)>
\ <_. )
`---' QUACK! Your code has been found GUILTY of type hinting!
Python is a dynamically typed language. Variables can be anything. They contain multitudes. Why constrain them with your bourgeois "type annotations"?
Every time you write def foo(x: int) -> str:, a duck somewhere loses its quack.
# Clone this repository
git clone https://github.com/mriley-cardinal/pywrong.git
# That's it. No pip install. No dependencies.
# Just pure, untyped Python.# Scan a single file
python pywrong.py myfile.py
# Scan a directory
python pywrong.py src/
# Scan current directory
python pywrong.py . __
___( o)>
\ <_. )
`---' QUACK! Your code has been found GUILTY of type hinting!
Scanning for type hint violations...
======================================================================
VIOLATIONS DETECTED
======================================================================
src/utils.py:12
Parameter 'name: str'? Just accept ANYTHING. That's the Python way!
>>> def greet(name: str) -> str:
src/utils.py:12
-> str? More like -> TRUST_ME_BRO. This is Python, not TypeScript.
>>> def greet(name: str) -> str:
src/models.py:5
Variable 'count: int'? Python variables are FREE. Let them BE.
>>> count: int = 0
======================================================================
3 type hints?! This code is basically Java with extra steps.
======================================================================
- Return type annotations:
-> int,-> str,-> List[Thing] - Parameter type hints:
def foo(x: int, y: str): - Variable annotations:
count: int = 0
- Type comments (
# type: ignoredoesn't count, you're still guilty) - Generic type aliases
typingmodule imports (but we're watching you)
Q: But type hints help with IDE autocomplete! A: Real Pythonistas read the source code.
Q: What about mypy and static analysis? A: What about FREEDOM?
Q: Isn't this just a joke? A: Quack.
Q: Should I actually use this in production? A: This linter is provided as-is. If you run it in CI and block your deploys, that's between you and the ducks.
MIT - Do whatever you want. Just like Python variables.
Found a type hint pattern we're not catching? Open an issue! Let's make the ducks proud.
"In the face of ambiguity, refuse the temptation to guess." — The Zen of Python
"In the face of type hints, refuse the temptation to annotate." — The Zen of pywrong