synapse-product/tests/handlers
David Robertson ffc2ee521d
Use mypy 1.0 (#15052)
* Update mypy and mypy-zope
* Remove unused ignores

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)

* Avoid empty body warnings, sometimes by marking methods as abstract

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]
```

* 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]
```

* Fix not calling `is_state()`

Oops!

```
tests/rest/client/test_third_party_rules.py:428: error: Function "Callable[[], bool]" could always be true in boolean context  [truthy-function]
```

* 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]
````

* Drive-by improvement to `wrapping_logic` annotation

* Workaround false "unreachable" positives

See https://github.com/Shoobx/mypy-zope/issues/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]
```

* Changelog

* Tweak DBAPI2 Protocol to be accepted by mypy 1.0

Some extra context in:
- https://github.com/matrix-org/python-canonicaljson/pull/57
- https://github.com/python/mypy/issues/6002
- https://mypy.readthedocs.io/en/latest/common_issues.html#covariant-subtyping-of-mutable-protocol-members-is-rejected

* Pull in updated canonicaljson lib

so the protocol check just works

* Improve comments in opentracing

I tried to workaround the ignores but found it too much trouble.

I think the corresponding issue is
https://github.com/python/mypy/issues/12909. The mypy repo has a PR
claiming to fix this (https://github.com/python/mypy/pull/14677) which
might mean this gets resolved soon?

* Better annotation for INTERACTIVE_AUTH_CHECKERS

* Drive-by AUTH_TYPE annotation, to remove an ignore
2023-02-16 16:09:11 +00:00
..
__init__.py Reference Matrix Home Server 2014-08-12 15:10:52 +01:00
oidc_test_key.p8 JWT OIDC secrets for Sign in with Apple (#9549) 2021-03-09 15:03:37 +00:00
oidc_test_key.pub.pem JWT OIDC secrets for Sign in with Apple (#9549) 2021-03-09 15:03:37 +00:00
test_admin.py Add more user information to export-data command. (#14894) 2023-02-01 15:45:19 +00:00
test_appservice.py Add final type hint to tests.unittest. (#15072) 2023-02-14 14:03:35 -05:00
test_auth.py Save login tokens in database (#13844) 2022-10-26 11:45:41 +01:00
test_cas.py Add final type hint to tests.unittest. (#15072) 2023-02-14 14:03:35 -05:00
test_deactivate_account.py Port the push rule classes to Rust. (#13768) 2022-09-20 12:10:31 +01:00
test_device.py Revert the deletion of stale devices due to performance issues. (#14662) 2022-12-12 13:55:23 +00:00
test_directory.py Add missing type hints to tests.handlers. (#14680) 2022-12-16 11:53:01 +00:00
test_e2e_keys.py Add final type hint to tests.unittest. (#15072) 2023-02-14 14:03:35 -05:00
test_e2e_room_keys.py Add missing type hints to tests.handlers. (#14680) 2022-12-16 11:53:01 +00:00
test_federation_event.py Add final type hint to tests.unittest. (#15072) 2023-02-14 14:03:35 -05:00
test_federation.py Add final type hint to tests.unittest. (#15072) 2023-02-14 14:03:35 -05:00
test_message.py Add final type hint to tests.unittest. (#15072) 2023-02-14 14:03:35 -05:00
test_oidc.py Add more missing type hints to tests. (#15028) 2023-02-08 16:29:49 -05:00
test_password_providers.py Add final type hint to tests.unittest. (#15072) 2023-02-14 14:03:35 -05:00
test_presence.py Add missing type hints to tests.handlers. (#14680) 2022-12-16 11:53:01 +00:00
test_profile.py Add missing type hints to tests.handlers. (#14680) 2022-12-16 11:53:01 +00:00
test_receipts.py Add missing type hints to tests.handlers. (#14680) 2022-12-16 11:53:01 +00:00
test_register.py Use mypy 1.0 (#15052) 2023-02-16 16:09:11 +00:00
test_room_member.py Faster joins: Refactor handling of servers in room (#14954) 2023-02-03 15:39:59 +00:00
test_room_summary.py Add missing type hints to tests.handlers. (#14680) 2022-12-16 11:53:01 +00:00
test_room.py Add missing type hints to tests.handlers. (#14680) 2022-12-16 11:53:01 +00:00
test_saml.py Add final type hint to tests.unittest. (#15072) 2023-02-14 14:03:35 -05:00
test_send_email.py Add missing type hints to tests.handlers. (#14680) 2022-12-16 11:53:01 +00:00
test_sso.py Add support for handling avatar with SSO login (#13917) 2022-11-25 15:16:50 +00:00
test_stats.py Add missing type hints to tests.handlers. (#14680) 2022-12-16 11:53:01 +00:00
test_sync.py Add missing type hints to tests.handlers. (#14680) 2022-12-16 11:53:01 +00:00
test_typing.py Add final type hint to tests.unittest. (#15072) 2023-02-14 14:03:35 -05:00
test_user_directory.py Add final type hint to tests.unittest. (#15072) 2023-02-14 14:03:35 -05:00