Skip to content

[mypy]: make mypy and pre-commit run mypy results differ #2414

@DerBiasto

Description

@DerBiasto

On the current master running make mypy yields the following list of errors for me:

$ mypy --version
mypy 0.800
$ mypy -p telegram
telegram/passport/credentials.py:182: error: Item "Ed25519PrivateKey" of "Union[Ed25519PrivateKey, Ed448PrivateKey, RSAPrivateKey, DSAPrivateKey, EllipticCurvePrivateKey]" has no attribute "decrypt"  [union-attr]
telegram/passport/credentials.py:182: error: Item "Ed448PrivateKey" of "Union[Ed25519PrivateKey, Ed448PrivateKey, RSAPrivateKey, DSAPrivateKey, EllipticCurvePrivateKey]" has no attribute "decrypt"  [union-attr]
telegram/passport/credentials.py:182: error: Item "DSAPrivateKey" of "Union[Ed25519PrivateKey, Ed448PrivateKey, RSAPrivateKey, DSAPrivateKey, EllipticCurvePrivateKey]" has no attribute "decrypt"  [union-attr]
telegram/passport/credentials.py:182: error: Item "EllipticCurvePrivateKey" of "Union[Ed25519PrivateKey, Ed448PrivateKey, RSAPrivateKey, DSAPrivateKey, EllipticCurvePrivateKey]" has no attribute "decrypt"  [union-attr]
telegram/ext/utils/webhookhandler.py:98: error: Module has no attribute "ProactorEventLoop"; maybe "SelectorEventLoop" or "AbstractEventLoop"?  [attr-defined]
telegram/ext/utils/webhookhandler.py:126: error: Module has no attribute "WindowsProactorEventLoopPolicy"; maybe "AbstractEventLoopPolicy"?  [attr-defined]
telegram/ext/utils/webhookhandler.py:143: error: Argument 2 to "__init__" of "Application" has incompatible type "List[Tuple[str, Type[WebhookHandler], Dict[str, object]]]"; expected "Optional[List[Union[Rule, List[Any], Tuple[Union[str, Matcher], Any], Tuple[Union[str, Matcher], Any, Dict[str, Any]], Tuple[Union[str, Matcher], Any, Dict[str, Any], str]]]]"  [arg-type]
telegram/ext/utils/webhookhandler.py:143: note: "List" is invariant -- see http://mypy.readthedocs.io/en/latest/common_issues.html#variance
telegram/ext/utils/webhookhandler.py:143: note: Consider using "Sequence" instead, which is covariant
telegram/ext/utils/webhookhandler.py:152: error: Incompatible types in assignment (expression has type "List[str]", base class "RequestHandler" defined the type as "Tuple[str, str, str, str, str, str, str]")  [assignment]
Found 6 errors in 2 files (checked 169 source files)

while running pre-commit run mypy (with a small irrelevant change, so it isn't just skipped) yields:

$ pre-commit run mypy
mypy.....................................................................Failed
- hook id: mypy
- exit code: 1

telegram/ext/utils/webhookhandler.py:98: error: Module has no attribute "ProactorEventLoop"; maybe "SelectorEventLoop" or "AbstractEventLoop"?  [attr-defined]
telegram/ext/utils/webhookhandler.py:126: error: Module has no attribute "WindowsProactorEventLoopPolicy"; maybe "AbstractEventLoopPolicy"?  [attr-defined]
Found 2 errors in 1 file (checked 2 source files)

As you can see, the two pre-commit errors are there aswell and fixing/ignoring them makes them go away in both cases.
Ignoring the other errors makes make mypy return without errors, but then the pre-commit version complains about unnecessary "type: ignore" comments.

I have not touched any configs and the mypy version should be identical, my python version is 3.8.5.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions