Commits on Feb 10, 2023
-
David Robertson committed
Feb 10, 2023 -
Suppress false positives from modules not implementing Protocols
Not sure why mypy is flagging these up now? Could be a mypy bug ``` synapse/__init__.py:67: error: Argument 1 to "set_json_library" has incompatible type Module; expected "JsonLibrary" [arg-type] synapse/__init__.py:67: note: Following member(s) of "Module json" have conflicts: synapse/__init__.py:67: note: JSONEncoder: expected "Encoder", got "Type[JSONEncoder]" synapse/storage/engines/postgres.py:38: error: Argument 1 to "__init__" of "BaseDatabaseEngine" has incompatible type Module; expected "DBAPI2Module" [arg-type] synapse/storage/engines/postgres.py:38: note: Following member(s) of "Module psycopg2" have conflicts: synapse/storage/engines/postgres.py:38: note: DataError: expected "Type[Exception]", got "Type[DataError]" synapse/storage/engines/postgres.py:38: note: DatabaseError: expected "Type[Exception]", got "Type[DatabaseError]" synapse/storage/engines/postgres.py:38: note: <9 more conflict(s) not shown> synapse/__init__.py:67: error: Argument 1 to "set_json_library" has incompatible type Module; expected "JsonLibrary" [arg-type] synapse/storage/engines/sqlite.py:29: error: Argument 1 to "__init__" of "BaseDatabaseEngine" has incompatible type Module; expected "DBAPI2Module" [arg-type] synapse/storage/engines/sqlite.py:29: note: Following member(s) of "Module sqlite3" have conflicts: synapse/storage/engines/sqlite.py:29: note: DataError: expected "Type[Exception]", got "Type[DataError]" synapse/storage/engines/sqlite.py:29: note: DatabaseError: expected "Type[Exception]", got "Type[DatabaseError]" synapse/storage/engines/sqlite.py:29: note: <9 more conflict(s) not shown> ```
David Robertson committedFeb 10, 2023 -
These used to suppress ``` synapse/storage/engines/__init__.py:28: error: "__new__" must return a class instance (got "NoReturn") [misc] ``` and ``` synapse/http/matrixfederationclient.py:1270: error: "BaseException" has no attribute "reasons" [attr-defined] ``` (note that we check `hasattr(e, "reasons")` above)
David Robertson committedFeb 10, 2023 -
E.g. ``` tests/handlers/test_register.py:58: error: Missing return statement [empty-body] tests/handlers/test_register.py:108: error: Missing return statement [empty-body] ```
David Robertson committedFeb 10, 2023 -
Suppress false positive about
JaegerConfig
Complaint was ``` synapse/logging/opentracing.py:450: error: Function "Type[Config]" could always be true in boolean context [truthy-function] ```
David Robertson committedFeb 10, 2023 -
Oops! ``` tests/rest/client/test_third_party_rules.py:428: error: Function "Callable[[], bool]" could always be true in boolean context [truthy-function] ```
David Robertson committedFeb 10, 2023 -
Suppress false positives from ParamSpecs
```` synapse/logging/opentracing.py:971: error: Argument 2 to "_custom_sync_async_decorator" has incompatible type "Callable[[Arg(Callable[P, R], 'func'), **P], _GeneratorContextManager[None]]"; expected "Callable[[Callable[P, R], **P], _GeneratorContextManager[None]]" [arg-type] synapse/logging/opentracing.py:1017: error: Argument 2 to "_custom_sync_async_decorator" has incompatible type "Callable[[Arg(Callable[P, R], 'func'), **P], _GeneratorContextManager[None]]"; expected "Callable[[Callable[P, R], **P], _GeneratorContextManager[None]]" [arg-type] ````
David Robertson committedFeb 10, 2023 -
Drive-by improvement to
wrapping_logic
annotationDavid Robertson committedFeb 10, 2023 -
Workaround false "unreachable" positives
See Shoobx/mypy-zope#91 ``` tests/http/test_proxyagent.py:626: error: Statement is unreachable [unreachable] tests/http/test_proxyagent.py:762: error: Statement is unreachable [unreachable] tests/http/test_proxyagent.py:826: error: Statement is unreachable [unreachable] tests/http/test_proxyagent.py:838: error: Statement is unreachable [unreachable] tests/http/test_proxyagent.py:845: error: Statement is unreachable [unreachable] tests/http/federation/test_matrix_federation_agent.py:151: error: Statement is unreachable [unreachable] tests/http/federation/test_matrix_federation_agent.py:452: error: Statement is unreachable [unreachable] tests/logging/test_remote_handler.py:60: error: Statement is unreachable [unreachable] tests/logging/test_remote_handler.py:93: error: Statement is unreachable [unreachable] tests/logging/test_remote_handler.py:127: error: Statement is unreachable [unreachable] tests/logging/test_remote_handler.py:152: error: Statement is unreachable [unreachable] ```
David Robertson committedFeb 10, 2023 -
David Robertson committed
Feb 10, 2023 -
David Robertson committed
Feb 10, 2023
Commits on Feb 15, 2023
-
Make UserInteractiveAuthChecker an ABC
I had to add two new linter ignores here, but it did detect an incomplete subclass in the tests.
David Robertson committedFeb 15, 2023 -
David Robertson committed
Feb 15, 2023 -
David Robertson committed
Feb 15, 2023 -
Tweak DBAPI2 Protocol to be accepted by mypy 1.0
Some extra context in: - matrix-org/python-canonicaljson#57 - python/mypy#6002 - https://mypy.readthedocs.io/en/latest/common_issues.html#covariant-subtyping-of-mutable-protocol-members-is-rejected
David Robertson committedFeb 15, 2023 -
Pull in updated canonicaljson lib
so the protocol check just works
David Robertson committedFeb 15, 2023
Commits on Feb 16, 2023
-
Improve comments in opentracing
I tried to workaround the ignores but found it too much trouble. I think the corresponding issue is python/mypy#12909. The mypy repo has a PR claiming to fix this (python/mypy#14677) which might mean this gets resolved soon?
David Robertson committedFeb 16, 2023 -
Better annotation for INTERACTIVE_AUTH_CHECKERS
David Robertson committedFeb 16, 2023 -
Drive-by AUTH_TYPE annotation, to remove an ignore
David Robertson committedFeb 16, 2023