Skip to content

Conversation

@AndrewFerr
Copy link
Member

@AndrewFerr AndrewFerr commented Oct 13, 2025

aka PEP 585, added in Python 3.9

Dev notes

Pull Request Checklist

  • Pull request is based on the develop branch
  • Pull request includes a changelog file. The entry should:
    • Be a short description of your change which makes sense to users. "Fixed a bug that prevented receiving messages from other servers." instead of "Moved X method from EventStore to EventWorkerStore.".
    • Use markdown where necessary, mostly for code blocks.
    • End with either a period (.) or an exclamation mark (!).
    • Start with a capital letter.
    • Feel free to credit yourself, by adding a sentence "Contributed by @github_username." or "Contributed by [Your Name]." to the end of the entry.
  • Code style is correct (run the linters)

aka PEP 585, added in Python 3.9
@AndrewFerr AndrewFerr requested a review from a team as a code owner October 13, 2025 02:34
@github-actions github-actions bot deployed to PR Documentation Preview October 13, 2025 02:35 Active
@github-actions github-actions bot deployed to PR Documentation Preview October 13, 2025 02:57 Active
Do so by locally allowing ruff's UP006 to apply fixes.
Do not set that permanently since it is an unsafe rule.
@github-actions github-actions bot deployed to PR Documentation Preview October 14, 2025 03:55 Active
@github-actions github-actions bot deployed to PR Documentation Preview October 15, 2025 20:56 Active
@github-actions github-actions bot deployed to PR Documentation Preview October 15, 2025 22:07 Active
Suppress some false-positive errors caused by migrating from typing.Type
@AndrewFerr AndrewFerr force-pushed the type-hinting-generics branch from 53eec57 to 3d079b9 Compare October 20, 2025 20:43
@github-actions github-actions bot deployed to PR Documentation Preview October 20, 2025 20:45 Active
@sandhose sandhose requested a review from a team October 21, 2025 07:11
@@ -0,0 +1 @@
Use type hinting generics in standard collections, as per PEP 585, added in Python 3.9.
Copy link
Contributor

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.

Copy link
Member Author

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: ignore comments
  • the removal of unused imports from __init__.py files (as doing so is an in-preview feature of the unused-import Ruff rule)
  • updates to docstrings, warnings, and comments (including # type: <type> comments) that referred to typing.* classes
  • updates to the type strings for TestFieldTypeInspection in scripts-dev/check_pydantic_models.py

Copy link
Contributor

@MadLittleMods MadLittleMods Oct 22, 2025

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:

  1. git checkout develop
  2. Start my own branch: git checkout -b madlittlemods/19046-see-diff
  3. Edit pyproject.toml with the new ruff rules
  4. Comment out ruff check --quiet --fix "${files[@]}" in scripts-dev/lint.sh so we can get to the auto-formatting part without it complaining
  5. Lint and auto-format: poetry run ./scripts-dev/lint.sh
  6. git commit -m "Auto-formatting changes"
  7. git fetch origin refs/pull/19046/head:pr-19046
  8. git diff madlittlemods/19046-see-diff pr-19046
  9. (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__.py

as it is unsafe only for Python <3.9, which Synapse no longer supports
@github-actions github-actions bot deployed to PR Documentation Preview October 22, 2025 18:41 Active
@github-actions github-actions bot deployed to PR Documentation Preview October 22, 2025 19:21 Active
@github-actions github-actions bot deployed to PR Documentation Preview October 22, 2025 20:54 Active
@MadLittleMods MadLittleMods merged commit fc244bb into element-hq:develop Oct 22, 2025
42 checks passed
@MadLittleMods
Copy link
Contributor

Thanks for moving the codebase forward @AndrewFerr 🐠

@AndrewFerr AndrewFerr deleted the type-hinting-generics branch October 23, 2025 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants