synapse-product/tests/rest/client
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 Remove redundant "coding: utf-8" lines (#9786) 2021-04-14 15:34:27 +01:00
test_account_data.py Add a module callback to react to account data changes (#12327) 2022-04-01 11:22:48 +02:00
test_account.py Add final type hint to tests.unittest. (#15072) 2023-02-14 14:03:35 -05:00
test_auth.py Use mypy 1.0 (#15052) 2023-02-16 16:09:11 +00:00
test_capabilities.py Add type hints to tests/rest/client (#12066) 2022-02-23 08:33:19 -05:00
test_consent.py Add type hints to tests/rest/client (#12072) 2022-02-24 13:56:38 -05:00
test_devices.py Fix dehydrated device REST checks (#14336) 2022-10-31 20:31:43 +00:00
test_directory.py Remove unnecessary json.dumps from tests (#13303) 2022-07-17 22:28:45 +01:00
test_ephemeral_message.py Add type hints to tests/rest/client (#12072) 2022-02-24 13:56:38 -05:00
test_events.py Additional constants for EDU types. (#12884) 2022-05-27 07:14:36 -04:00
test_filter.py Add final type hint to tests.unittest. (#15072) 2023-02-14 14:03:35 -05:00
test_identity.py Drop support for calling /_matrix/client/v3/rooms/{roomId}/invite without an id_access_token (#13241) 2022-08-31 12:10:25 +00:00
test_keys.py Cancel the processing of key query requests when they time out. (#13680) 2022-09-07 12:03:32 +01:00
test_login_token_request.py Respond with proper error responses on unknown paths. (#14621) 2022-12-08 11:37:05 -05:00
test_login.py Refactor OIDC tests to better mimic an actual OIDC provider. (#13910) 2022-10-25 14:25:02 +00:00
test_models.py A third batch of Pydantic validation for rest/client/account.py (#13736) 2022-09-15 18:36:02 +01:00
test_mutual_rooms.py Mutual rooms: Remove dependency on user directory (#12836) 2022-05-30 10:05:31 +01:00
test_notifications.py Fix invite notifications for users without pushers (#12840) 2022-05-30 13:14:43 +02:00
test_password_policy.py Remove unnecessary json.dumps from tests (#13303) 2022-07-17 22:28:45 +01:00
test_power_levels.py Add type hints to tests/rest/client (#12072) 2022-02-24 13:56:38 -05:00
test_presence.py Add final type hint to tests.unittest. (#15072) 2023-02-14 14:03:35 -05:00
test_profile.py annotate tests.server.FakeChannel (#13136) 2022-07-04 18:08:56 +01:00
test_push_rule_attrs.py Add type hints to tests/rest/client (#12084) 2022-02-28 17:47:37 +00:00
test_receipts.py Reject receipt requests with invalid room or event IDs. (#14632) 2022-12-07 17:35:41 +00:00
test_redactions.py Implement MSC3912: Relation-based redactions (#14260) 2022-11-03 16:21:31 +00:00
test_register.py Add final type hint to tests.unittest. (#15072) 2023-02-14 14:03:35 -05:00
test_relations.py Implement MSC3925: changes to bundling of edits (#14811) 2023-01-10 16:31:28 +00:00
test_rendezvous.py Respond with proper error responses on unknown paths. (#14621) 2022-12-08 11:37:05 -05:00
test_report_event.py Prevent clients from reporting nonexistent events. (#13779) 2023-02-14 15:50:59 +00:00
test_retention.py Add final type hint to tests.unittest. (#15072) 2023-02-14 14:03:35 -05:00
test_room_batch.py Remove remaining bits of groups code. (#12936) 2022-06-01 09:41:25 -04:00
test_rooms.py Add final type hint to tests.unittest. (#15072) 2023-02-14 14:03:35 -05:00
test_sendtodevice.py Additional constants for EDU types. (#12884) 2022-05-27 07:14:36 -04:00
test_shadow_banned.py Add final type hint to tests.unittest. (#15072) 2023-02-14 14:03:35 -05:00
test_sync.py Fix type hints in knocking tests. (#14887) 2023-01-25 14:38:20 -05:00
test_third_party_rules.py Use mypy 1.0 (#15052) 2023-02-16 16:09:11 +00:00
test_transactions.py Add missing type hints in tests (#14879) 2023-01-26 14:45:24 -05:00
test_typing.py Do not allow a None-limit on PaginationConfig. (#14146) 2022-10-14 12:30:05 +00:00
test_upgrade_room.py Add final type hint to tests.unittest. (#15072) 2023-02-14 14:03:35 -05:00
utils.py Implement MSC3912: Relation-based redactions (#14260) 2022-11-03 16:21:31 +00:00