-
Notifications
You must be signed in to change notification settings - Fork 404
Use type hinting generics in standard collections #19046
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use type hinting generics in standard collections #19046
Conversation
aka PEP 585, added in Python 3.9
Do so by locally allowing ruff's UP006 to apply fixes. Do not set that permanently since it is an unsafe rule.
Suppress some false-positive errors caused by migrating from typing.Type
53eec57 to
3d079b9
Compare
| @@ -0,0 +1 @@ | |||
| Use type hinting generics in standard collections, as per PEP 585, added in Python 3.9. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's very hard to review this thoroughly as I don't want to click through 539 files on this diff. From a random sampling, I'm going to consider this good enough ✅
Due to the large number of changes in this pull request, only one file is being shown at a time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What should alleviate that concern somewhat is the auto-fix rule for this PIP being enabled (b6f7a91), and lint/format/type checkers being satisfied with it.
The only handmade changes in this PR are:
- the two new
# type: ignorecomments - the removal of unused imports from
__init__.pyfiles (as doing so is an in-preview feature of theunused-importRuff rule) - updates to docstrings, warnings, and comments (including
# type: <type>comments) that referred totyping.*classes - updates to the type strings for
TestFieldTypeInspectionin scripts-dev/check_pydantic_models.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is what I also did:
git checkout develop- Start my own branch:
git checkout -b madlittlemods/19046-see-diff - Edit
pyproject.tomlwith the newruffrules - Comment out
ruff check --quiet --fix "${files[@]}"inscripts-dev/lint.shso we can get to the auto-formatting part without it complaining - Lint and auto-format:
poetry run ./scripts-dev/lint.sh git commit -m "Auto-formatting changes"git fetch origin refs/pull/19046/head:pr-19046git diff madlittlemods/19046-see-diff pr-19046- (I looked through the actual diff here, looks sane ✅)
Summary:
$ git diff madlittlemods/19046-see-diff pr-19046 --numstat | xclip -selection clipboard
2 2 build_rust.py
1 0 changelog.d/19046.misc
54 58 pyproject.toml # This is just auto-formatting from my own `pyproject.toml` editing in VSCode
7 7 scripts-dev/check_pydantic_models.py
1 1 synapse/__init__.py
1 1 synapse/_scripts/synapse_port_db.py
1 1 synapse/api/auth/__init__.py
0 2 synapse/appservice/__init__.py
3 1 synapse/config/saml2.py
0 4 synapse/events/__init__.py
0 3 synapse/federation/sender/__init__.py
1 1 synapse/federation/transport/server/__init__.py
1 1 synapse/federation/transport/server/_base.py
8 8 synapse/handlers/auth.py
3 1 synapse/handlers/oidc.py
1 1 synapse/handlers/sliding_sync/__init__.py
1 1 synapse/logging/context.py
0 4 synapse/metrics/__init__.py
0 3 synapse/module_api/__init__.py
1 1 synapse/notifier.py
1 1 synapse/push/__init__.py
1 1 synapse/rest/__init__.py
1 1 synapse/rest/admin/__init__.py
2 2 synapse/rest/admin/users.py
0 6 synapse/state/__init__.py
1 1 synapse/state/v2.py
1 1 synapse/storage/databases/__init__.py
1 1 synapse/storage/databases/main/__init__.py
1 1 synapse/storage/databases/main/events_bg_updates.py
1 1 synapse/storage/databases/main/registration.py
1 1 synapse/streams/__init__.py
0 5 synapse/types/__init__.py
1 1 synapse/types/handlers/__init__.py
1 1 synapse/types/rest/client/__init__.py
0 2 synapse/util/__init__.py
1 1 synapse/util/caches/__init__.py
0 1 tests/http/__init__.py
1 1 tests/push/test_email.py
1 1 tests/test_utils/__init__.pyas it is unsafe only for Python <3.9, which Synapse no longer supports
|
Thanks for moving the codebase forward @AndrewFerr 🐠 |
aka PEP 585, added in Python 3.9
Dev notes
Pull Request Checklist
EventStoretoEventWorkerStore.".code blocks.