1
0
Fork 0
mirror of https://github.com/element-hq/synapse.git synced 2025-03-31 03:45:13 +00:00
Commit graph

193 commits

Author SHA1 Message Date
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
Dirk Klimpel
50ae4eafe1
Add some type hints to event_federation datastore ()
Co-authored-by: David Robertson <david.m.robertson1@gmail.com>
2022-05-18 16:02:10 +01:00
Dirk Klimpel
6edefef602
Add some type hints to datastore () 2022-05-17 15:29:06 +01:00
David Robertson
1fe202a1a3
Tidy up and type-hint the database engine modules ()
Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
2022-05-17 00:34:38 +01:00
David Robertson
aec69d2481
Another batch of type annotations () 2022-05-13 12:35:31 +01:00
David Robertson
17e1eb7749
Reduce the number of "untyped defs" () 2022-05-12 14:33:50 +00:00
andrew do
01e625513a
remove constantly lib use and switch to enums. () 2022-05-04 11:26:11 +00:00
David Robertson
01dcf7532d
Prune mypy ignore_missing_imports list () 2022-05-03 11:03:20 +01:00
David Robertson
30c8e7e408
Make scripts-dev pass mypy --disallow-untyped-defs ()
Not enforced in config yet. One day.
2022-04-27 13:10:31 +00:00
David Robertson
6463244375
Remove unused # type: ignores ()
Over time we've begun to use newer versions of mypy, typeshed, stub
packages---and of course we've improved our own annotations. This makes
some type ignore comments no longer necessary. I have removed them.

There was one exception: a module that imports `select.epoll`. The
ignore is redundant on Linux, but I've kept it ignored for those of us
who work on the source tree using not-Linux. ()

I'm more interested in the config line which enforces this. I want
unused ignores to be reported, because I think it's useful feedback when
annotating to know when you've fixed a problem you had to previously
ignore.

* Installing extras before typechecking

Lacking an easy way to install all extras generically, let's bite the bullet and
make install the hand-maintained `all` extra before typechecking.

Now that https://github.com/matrix-org/backend-meta/pull/6 is merged to
the release/v1 branch.
2022-04-27 14:03:44 +01:00
David Robertson
09b4f6e46d
Remove leftover references to setup.py ()
* Remove leftover references to setup.py

Missed in .

* Changelog
2022-04-20 18:16:49 +00:00
David Robertson
e5a76ec00b
Dump setuptools; correct pyproject version number () 2022-04-20 17:33:20 +01:00
Patrick Cloke
4586119f0b
Add missing type hints to config classes. () 2022-04-11 12:07:23 -04:00
David Robertson
961ee75a9b
Disallow untyped defs in synapse._scripts ()
Of note: 

* No untyped defs in `register_new_matrix_user`

This one might be contraversial. `request_registration` has three
dependency-injection arguments used for testing. I'm removing the
injection of the `requests` module and using `unitest.mock.patch` in the
test cases instead.

Doing `reveal_type(requests)` and `reveal_type(requests.get)` before the
change:

```
synapse/_scripts/register_new_matrix_user.py:45: note: Revealed type is "Any"
synapse/_scripts/register_new_matrix_user.py:46: note: Revealed type is "Any"
```

And after:

```
synapse/_scripts/register_new_matrix_user.py:44: note: Revealed type is "types.ModuleType"
synapse/_scripts/register_new_matrix_user.py:45: note: Revealed type is "def (url: Union[builtins.str, builtins.bytes], params: Union[Union[_typeshed.SupportsItems[Union[builtins.str, builtins.bytes, builtins.int, builtins.float], Union[builtins.str, builtins.bytes, builtins.int, builtins.float, typing.Iterable[Union[builtins.str, builtins.bytes, builtins.int, builtins.float]], None]], Tuple[Union[builtins.str, builtins.bytes, builtins.int, builtins.float], Union[builtins.str, builtins.bytes, builtins.int, builtins.float, typing.Iterable[Union[builtins.str, builtins.bytes, builtins.int, builtins.float]], None]], typing.Iterable[Tuple[Union[builtins.str, builtins.bytes, builtins.int, builtins.float], Union[builtins.str, builtins.bytes, builtins.int, builtins.float, typing.Iterable[Union[builtins.str, builtins.bytes, builtins.int, builtins.float]], None]]], builtins.str, builtins.bytes], None] =, data: Union[Any, None] =, headers: Union[Any, None] =, cookies: Union[Any, None] =, files: Union[Any, None] =, auth: Union[Any, None] =, timeout: Union[Any, None] =, allow_redirects: builtins.bool =, proxies: Union[Any, None] =, hooks: Union[Any, None] =, stream: Union[Any, None] =, verify: Union[Any, None] =, cert: Union[Any, None] =, json: Union[Any, None] =) -> requests.models.Response"
```

* Drive-by comment in `synapse.storage.types`

* No untyped defs in `synapse_port_db`

This was by far the most painful. I'm happy to break this up into
smaller pieces for review if it's not managable as-is.
2022-04-11 12:41:55 +01:00
David Robertson
0cd182f296
Make synapse._scripts pass typechecks () 2022-04-08 14:00:12 +00:00
Jorge Florian
78e4d96a4d
Add missing type definitions for scripts in docker folder ()
Signed-off-by: Jorge Florian <jafn28@gmail.com>
2022-04-08 10:10:58 +00:00
Dirk Klimpel
d666fc02fa
Add type hints to some tests files () 2022-04-05 13:54:41 +01:00
David Robertson
80839a44f1
Remove more dead/broken dev scripts () 2022-04-03 21:21:08 +01:00
Richard van der Hoff
f0b03186d9
Add type hints for tests/unittest.py. ()
In particular, add type hints for get_success and friends, which are then helpful in a bunch of places.
2022-04-01 16:04:16 +00:00
David Robertson
336bff1104
Burn check_signature dev script. () 2022-04-01 13:41:42 +00:00
David Robertson
21351820e0
Remove list_url_patterns dev script () 2022-04-01 13:05:21 +00:00
Patrick Cloke
11df4ec6c2
Add more type hints to the main state store. () 2022-03-31 13:38:09 -04:00
David Robertson
e0bb268134
Fix typechecker problems exposed by signedjson 1.1.2 () 2022-03-29 21:37:50 +00:00
Dirk Klimpel
ac95167d2f
Add some type hints to datastore. () 2022-03-28 14:11:14 -04:00
Dirk Klimpel
9d21ecf7ce
Add type hints to tests files. () 2022-03-21 09:43:16 -04:00
Dirk Klimpel
c46065fa3d
Add some type hints to datastore ()
* inherit `MonthlyActiveUsersStore` from `RegistrationWorkerStore`

Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
2022-03-18 15:24:18 +00:00
Dirk Klimpel
9e06e22064
Add type hints to more tests files. () 2022-03-17 07:25:50 -04:00
Dirk Klimpel
5dd949bee6
Add type hints to some tests/handlers files. () 2022-03-15 09:16:37 -04:00
Dirk Klimpel
32c828d0f7
Add type hints to tests/rest. ()
Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
2022-03-11 12:42:22 +00:00
Erik Johnston
2ce27a24fe
Add experimental environment variable to enable asyncio reactor () 2022-03-08 13:23:18 +00:00
Dirk Klimpel
7e91107be1
Add type hints to tests/rest ()
* Add type hints to `tests/rest`

* newsfile

* change import from `SigningKey`
2022-03-03 16:05:44 +00:00
David Robertson
1fbe0316a9
Add suffices to scripts in scripts-dev ()
* Rename scripts-dev to have suffices

* Update references to `scripts-dev`

* Changelog

* These scripts don't pass mypy
2022-03-02 18:00:26 +00:00