Commit Graph

224 Commits

Author SHA1 Message Date
Patrick Cloke
c369d82df0
Add missing type hints to InsecureInterceptableContextFactory. () 2023-02-28 10:17:55 -05:00
Patrick Cloke
c9b9143655
Fix-up type hints in tests/server.py. ()
This file was being ignored by mypy, we remove that
and add the missing type hints & deal with any fallout.
2023-02-17 18:19:38 +00:00
Patrick Cloke
42aea0d8af
Add final type hint to tests.unittest. ()
Adds a return type to HomeServerTestCase.make_homeserver and deal
with any variables which are no longer Any.
2023-02-14 14:03:35 -05:00
Patrick Cloke
733531ee3e
Add final type hint to synapse.server. () 2023-02-09 09:49:04 -05:00
David Robertson
7081bb56e2
Proper types for tests.module_api ()
* -> None for test methods

* A first batch of type fixes

* Introduce common parent test case

* Fixup that big test method

* tests.module_api passes mypy

* Changelog
2023-02-09 00:23:35 +00:00
Patrick Cloke
30509a1010
Add more missing type hints to tests. () 2023-02-08 16:29:49 -05:00
Patrick Cloke
4eed7b2ede
Add missing type hints to tests. () 2023-02-08 19:52:37 +00:00
Patrick Cloke
975f7ba904
Explicit disabling of disallowed_untyped_defs. ()
To make it easier to see which files still need to be fixed.
2023-02-08 18:49:18 +00:00
David Robertson
2dff93099b
Typecheck tests.rest.media.v1.test_media_storage ()
* Fix MediaStorage type hint

* Typecheck tests.rest.media.v1.test_media_storage

* Changelog

* Remove assert and make the comment succinct

* Fix syntax for olddeps
2023-02-07 15:24:44 +00:00
David Robertson
4dd2b6165c
Proper types for tests.test_terms_auth ()
* Proper types for tests.test_terms_auth

* Changelog
2023-02-07 12:03:39 +00:00
David Robertson
d0fed7a37b
Properly typecheck types.http ()
* Tweak http types in Synapse

AFACIS these are correct, and they make mypy happier on tests.http.

* Type hints for test_proxyagent

* type hints for test_srv_resolver

* test_matrix_federation_agent

* tests.http.server._base

* tests.http.__init__

* tests.http.test_additional_resource

* tests.http.test_client

* tests.http.test_endpoint

* tests.http.test_matrixfederationclient

* tests.http.test_servlet

* tests.http.test_simple_client

* tests.http.test_site

* One fixup in tests.server

* Untyped defs

* Changelog

* Fixup syntax for Python 3.7

* Fix olddeps syntax

* Use a twisted IPv4 addr for dummy_address

* Fix typo, thanks Sean

Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>

* Remove redundant `Optional`

---------

Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
2023-02-07 00:20:04 +00:00
Patrick Cloke
d0fa217cd9
Add missing types to test_state. () 2023-02-06 16:11:09 +00:00
David Robertson
0f34abed7c
Type hints for tests.federation ()
* Make tests.federation pass mypy

* Untyped defs in tests.federation.transport

* test methods return None

* Remaining type hints in tests.federation

* Changelog

* Avoid an uncessary type-ignore
2023-02-06 16:05:06 +00:00
Patrick Cloke
156cd88eef
Add missing type hints to tests.replication. () 2023-02-06 09:55:00 -05:00
David Robertson
b275763c65
Expect type stubs from canonicaljson ()
* canonicaljson has stubs now

since https://github.com/matrix-org/python-canonicaljson/pull/52

which is included in the lockfile version we use for type checking.

* Changelog
2023-02-06 12:54:11 +00:00
David Robertson
e8269ed391
Type hints for tests.appservice ()
* Accept a Sequence of events in synapse.appservice

This avoids some casts/ignores in the tests I'm about to fixup. It seems
that `List[Mock]` is not a subtype of `List[EventBase]`, but
`Sequence[Mock]` is a subtype of `Sequence[EventBase]`. So presumably
`Mock` is considered a subtype of anything, much like `Any`.

* make tests.appservice.test_scheduler pass mypy

* Extra hints in tests.appservice.test_scheduler

* Extra hints in tests.appservice.test_api

* Extra hints in tests.appservice.test_appservice

* Disallow untyped defs

* Changelog
2023-02-06 12:49:06 +00:00
David Robertson
6e6edea6c1
Properly typecheck tests.api () 2023-02-03 20:03:23 +00:00
David Robertson
e301ee6189
Properly typecheck tests.app ( 2023-02-03 19:22:40 +00:00
Patrick Cloke
fc35e0673f
Add missing type hints in tests ()
* FIx-up type hints in tests.logging.
* Add missing type hints to test_transactions.
2023-01-26 14:45:24 -05:00
Andrew Morgan
871ff05add
Fix type hints in typing edu unit tests () 2023-01-26 10:15:50 +00:00
Patrick Cloke
3c3ba31507
Add missing type hints for tests.events. () 2023-01-25 15:14:03 -05:00
Andrew Morgan
836c592f15
Fix type hints in knocking tests. () 2023-01-25 14:38:20 -05:00
Andrew Morgan
f075f6ae2b
Fix type hints for Monthly Active Users tests () 2023-01-22 10:50:14 +01:00
Andrew Morgan
8d90e5f200
Add type hints to TestRatelimiter () 2023-01-21 15:59:15 +00:00
Patrick Cloke
7f2cabf271
Fix-up type hints for tests.push module. () 2023-01-11 07:35:40 -05:00
Patrick Cloke
a4ca770655
Add missing type hints to tests. ()
Adds type hints to tests.metrics and tests.crypto.
2022-12-28 08:29:35 -05:00
Patrick Cloke
3aeca2588b
Add missing type hints to tests.config. () 2022-12-16 08:53:28 -05:00
Patrick Cloke
652d1669c5
Add missing type hints to tests.handlers. ()
And do not allow untyped defs in tests.handlers.
2022-12-16 11:53:01 +00:00
David Robertson
e2a1adbf5d
Allow selecting "prejoin" events by state keys ()
* Declare new config

* Parse new config

* Read new config

* Don't use trial/our TestCase where it's not needed

Before:

```
$ time trial tests/events/test_utils.py > /dev/null

real	0m2.277s
user	0m2.186s
sys	0m0.083s
```

After:
```
$ time trial tests/events/test_utils.py > /dev/null

real	0m0.566s
user	0m0.508s
sys	0m0.056s
```

* Helper to upsert to event fields

without exceeding size limits.

* Use helper when adding invite/knock state

Now that we allow admins to include events in prejoin room state with
arbitrary state keys, be a good Matrix citizen and ensure they don't
accidentally create an oversized event.

* Changelog

* Move StateFilter tests

should have done this in 

* Add extra methods to StateFilter

* Use StateFilter

* Ensure test file enforces typed defs; alphabetise

* Workaround surprising get_current_state_ids

* Whoops, fix mypy
2022-12-13 00:54:46 +00:00
David Robertson
3d87847ecc
Enable --warn-redundant-casts option in mypy ()
* Enable `--warn-redundant-casts` option in mypy

Doesn't do much but helps me sleep better at night.

* Changelog

* Fix name of the ignore

* Fix one more missed cast

Not sure why I didn't see this one locally, maybe I needed a poetry update

* Remove old comment

Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>

Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
2022-12-12 21:25:07 +00:00
Patrick Cloke
3ac412b4e2
Require types in tests.storage. ()
Adds missing type hints to `tests.storage` package
and does not allow untyped definitions.
2022-12-09 12:36:32 -05:00
Patrick Cloke
acea4d7a2f
Add missing types to tests.util. ()
Removes files under tests.util from the ignored by list, then
fully types all tests/util/*.py files.
2022-12-02 17:58:56 +00:00
Ashish Kumar
09de2aecb0
Add support for handling avatar with SSO login ()
This commit adds support for handling a provided avatar picture URL
when logging in via SSO.

Signed-off-by: Ashish Kumar <ashfame@users.noreply.github.com>

Fixes .
2022-11-25 15:16:50 +00:00
Patrick Cloke
4ae967cf63
Add missing type hints to test.util.caches () 2022-11-22 17:35:54 -05:00
Andrew Morgan
ae22e6e94f
Enable 'strict_equality' checking for mypy () 2022-11-17 18:34:09 +00:00
David Robertson
115f0eb233
Reintroduce , with bugfix for monoliths ()
* Add tests for StreamIdGenerator

* Drive-by: annotate all defs

* Revert "Revert "Remove slaved id tracker ()" ()"

This reverts commit d63814fd73, which in
turn reverted 36097e88c4. This restores
the latter.

* Fix StreamIdGenerator not handling unpersisted IDs

Spotted by @erikjohnston.

Closes .

* Changelog

Co-authored-by: Nick Mills-Barrett <nick@fizzadar.com>
Co-authored-by: Erik Johnston <erik@matrix.org>
2022-11-16 22:16:46 +00:00
David Robertson
2bb2c32e8e
Avoid incrementing bg process utime/stime counters by negative durations () 2022-10-31 13:02:07 +00:00
David Robertson
e9a0419c8d
Fix sending events into rooms with non-integer power levels () 2022-10-06 13:00:03 +00:00
Erik Johnston
c9b7e97355
Add a stub Rust crate () 2022-09-06 19:01:37 +01:00
David Robertson
d642ce4b32
Use Pydantic to systematically validate a first batch of endpoints in synapse.rest.client.account. () 2022-08-15 19:05:57 +00:00
Patrick Cloke
50122754c8
Add missing types to opentracing. ()
After this change `synapse.logging` is fully typed.
2022-07-21 12:01:52 +00:00
David Robertson
6ba732fefe
Type tests.utils ()
* Cast to postgres types when handling postgres db

* Remove unused method

* Easy annotations

* Annotate create_room

* Use `ParamSpec` to annotate looping_call

* Annotate `default_config`

* Track `now` as a float

`time_ms` returns an int like the proper Synapse `Clock`

* Introduce a `Timer` dataclass

* Introduce a Looper type

* Suppress checking of a mock

* tests.utils is typed

* Changelog

* Whoops, import ParamSpec from typing_extensions

* ditch the psycopg2 casts
2022-07-05 15:13:47 +01:00
Andrew Morgan
9820665597
Remove tests/utils.py from mypy's exclude list () 2022-07-04 15:15:33 +01:00
Patrick Cloke
6ad012ef89
More type hints for synapse.logging ()
Completes type hints for synapse.logging.scopecontextmanager and (partially)
for synapse.logging.opentracing.
2022-06-30 13:05:06 +00:00
David Robertson
09f6e43025
Actually typecheck tests.test_server () 2022-06-30 10:45:47 +01:00
David Robertson
f1145563f6
Extra type annotations in test_server () 2022-06-28 12:12:17 +00:00
David Robertson
97e9fbe1b2
Type annotations in synapse.databases.main.devices ()
Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
2022-06-15 15:20:04 +00:00
David Robertson
97053c9406
Type annotations for test_v2 () 2022-06-09 09:48:04 +01:00
Dirk Klimpel
444588c5fc
Add some type hints to tests files ()
Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
2022-05-23 11:23:26 +00:00
David Robertson
b935c9529c
Simplify untyped-defs config in mypy.ini () 2022-05-19 13:49:58 +01:00