Skip to content

Write union types as X | Y where possible#19111

Merged
MadLittleMods merged 18 commits intoelement-hq:developfrom
AndrewFerr:union-type-annotations
Nov 6, 2025
Merged

Write union types as X | Y where possible#19111
MadLittleMods merged 18 commits intoelement-hq:developfrom
AndrewFerr:union-type-annotations

Conversation

@AndrewFerr
Copy link
Copy Markdown
Member

@AndrewFerr AndrewFerr commented Oct 29, 2025

aka PEP 604, added in Python 3.10

This PR has been broken down into multiple commits, to illustrate the steps used to prepare it.

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)

@AndrewFerr AndrewFerr requested a review from a team as a code owner October 29, 2025 17:48
@github-actions github-actions bot deployed to PR Documentation Preview October 29, 2025 17:49 Active
@github-actions github-actions bot deployed to PR Documentation Preview October 29, 2025 17:51 Active
@AndrewFerr AndrewFerr changed the title Use union type annotations Write union types as X | Y where possible Oct 29, 2025
as `X | Y` is used not only for annotations, but also type aliases
@github-actions github-actions bot deployed to PR Documentation Preview October 29, 2025 17:53 Active
@AndrewFerr
Copy link
Copy Markdown
Member Author

The trial-olddeps failure is caused by using Pydantic v1, which won't support Python 3.10: pydantic/pydantic#2607 (comment)

Thankfully, there's already a PR for enforcing Pydantic v2: #19071

@github-actions github-actions bot deployed to PR Documentation Preview October 31, 2025 13:38 Active
@AndrewFerr
Copy link
Copy Markdown
Member Author

The Pydantic update indeed fixed trial-olddeps.

I believe the current Complement test failure (TestPartialStateJoin/joined_members_blocks_during_partial_state_join) is a false-positive, as I recall it sometimes failing in other unrelated PRs.

@github-actions github-actions bot deployed to PR Documentation Preview November 3, 2025 14:52 Active
@github-actions github-actions bot deployed to PR Documentation Preview November 3, 2025 22:04 Active
@github-actions github-actions bot deployed to PR Documentation Preview November 4, 2025 13:06 Active
@MadLittleMods MadLittleMods requested a review from a team November 4, 2025 19:15
@github-actions github-actions bot deployed to PR Documentation Preview November 6, 2025 18:30 Active
@github-actions github-actions bot deployed to PR Documentation Preview November 6, 2025 18:52 Active
@MadLittleMods MadLittleMods merged commit fcac7e0 into element-hq:develop Nov 6, 2025
72 of 74 checks passed
@AndrewFerr AndrewFerr deleted the union-type-annotations branch November 7, 2025 05:35
devonh pushed a commit that referenced this pull request Nov 10, 2025
Ignore Python language refactors (`.git-blame-ignore-revs`)

 - #19046
 - #19111

### Pull Request Checklist

<!-- Please read
https://element-hq.github.io/synapse/latest/development/contributing_guide.html
before submitting your pull request -->

* [x] Pull request is based on the develop branch
* [x] Pull request includes a [changelog
file](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#changelog).
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.
* [x] [Code
style](https://element-hq.github.io/synapse/latest/code_style.html) is
correct (run the
[linters](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#run-the-linters))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants