Skip to content

Update all code left-overs to 3.10+ - #1041

Merged
provinzkraut merged 11 commits into
msgspec:mainfrom
sobolevn:upgrade-3.10
Jun 11, 2026
Merged

provinzkraut merged 11 commits into
msgspec:mainfrom
sobolevn:upgrade-3.10

Conversation

@sobolevn

@sobolevn sobolevn commented Jun 7, 2026

Copy link
Copy Markdown
Member

Things I used:

  • pyupgrade
  • A lot of manual labour 😅

Considerations:

  • I checked that both new and old type forms are covered with tests
  • I double checked that no particular APIs require older type forms (typing._GenericAlias vs types.GenericAlias difference)

Comment thread src/msgspec/_utils.py Resolved
Comment thread tests/unit/test_common.py Resolved
@sobolevn

sobolevn commented Jun 11, 2026 •

Copy link
Copy Markdown
Member Author

@provinzkraut does this look better now? :)
I want to merge this, because my frozendict PR (#1052) would have lots of conflicts.

@provinzkraut

Copy link
Copy Markdown
Member

@provinzkraut does this look better now? :) I want to merge this, because my frozendict PR would have lots of conflicts.

I'll check it out later today!

@ofek

ofek commented Jun 11, 2026

Copy link
Copy Markdown
Member

I was going to take a look but noticed that this needs to be rebased.

@sobolevn

Copy link
Copy Markdown
Member Author

Oups, updated!

Comment thread tests/unit/test_inspect.py Resolved
@provinzkraut

Copy link
Copy Markdown
Member

@sobolevn all good from my side, except one open question

@provinzkraut
provinzkraut added this pull request to the merge queue Jun 11, 2026
Merged via the queue into msgspec:main with commit 03013da Jun 11, 2026
25 checks passed
amrebrahim682-spec

This comment was marked as spam.

pull Bot pushed a commit to Future-Outlier/msgspec that referenced this pull request Sep 14, 2026
Widening the runtime to accept `None` was the alternative. I rejected
it: the docstring specifies `offset : int, optional` and reserves `-1`
as the sentinel for writing at the end of the buffer, which leaves
`None` with no meaning to carry. Narrowing the stub makes the declared
type match both the C code and the documented contract.

The `int | None` traces back to the original `Optional[int]` annotation
and survived the 3.10+ syntax migration in msgspec#1041. Nothing in the tree
passes `None`.

Residual limitation: this edits the same two stub lines as open PR
msgspec#1160, which reshapes `buffer` and the return type while keeping
`offset: int | None`. Whichever lands second needs a one-line rebase.
The two changes are otherwise independent, since msgspec#1160 keeps reading
`offset` via `PyLong_AsSsize_t`.

Measurement, CPython 3.14:

- `just test-typing` clean under mypy 2.3.0, pyright 1.1.411, pyrefly
1.2.0.
- Reverting the stub hunk alone makes all three checkers fail on both
new call sites in `basic_typing_examples.py`, so the type-level test is
not vacuous.
- `pytest tests/unit`: 6119 passed, 404 skipped, identical to the
pre-change baseline. The two runtime assertions are pins on current
behavior rather than new coverage.
- `ruff format` collapses the signature onto one line once `| None` is
gone; that reformat is included.

No changelog entry, following merged stub PRs msgspec#1055, msgspec#1057, msgspec#1062,
msgspec#1065, msgspec#1074 and msgspec#1093, which leave it to the aggregated "type stub
improvements" line at release.

Co-authored-by: Dylan Pulver <[email protected]>
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.

4 participants