hauntsaninja / mypy_primer

Run mypy and pyright over millions of lines of code
MIT License
55 stars 29 forks source link

Should we run mypy with --check-untyped-defs? #66

Closed Akuli closed 1 year ago

Akuli commented 1 year ago

By default, mypy doesn't look inside bodies of untyped functions (that is, functions that have no parameter or return value annotations). With --check-untyped-defs it does.

$ cat asd.py
def foo():
    print(1 + "asd")

$ mypy asd.py
Success: no issues found in 1 source file

$ mypy --check-untyped-defs asd.py
asd.py:2: error: Unsupported operand types for + ("int" and "str")
Found 1 error in 1 file (checked 1 source file)

Checking untyped functions in mypy_primer could be useful if they call other functions that have stubs in typeshed. Some projects in mypy_primer (e.g. https://github.com/enthought/comtypes ) contain lots of untyped functions.

hauntsaninja commented 1 year ago

Good question, see https://github.com/hauntsaninja/mypy_primer/issues/64#issuecomment-1336864999

hauntsaninja commented 1 year ago

(closing as a duplicate of #64)