Skip to content

Update/regenerate various ruff_python_stdlib APIs#25273

Merged
AlexWaygood merged 1 commit into
mainfrom
regenerate-ruff-python-stdlib
May 20, 2026
Merged

Update/regenerate various ruff_python_stdlib APIs#25273
AlexWaygood merged 1 commit into
mainfrom
regenerate-ruff-python-stdlib

Conversation

@AlexWaygood
Copy link
Copy Markdown
Member

@AlexWaygood AlexWaygood commented May 20, 2026

Summary

  1. Manually update various functions in crates/ruff_python_stdlib/src/builtins.rs to reflect new APIs added in Python 3.15.
  2. Manually remove the incorrect inclusion of frozenset from is_immutable_non_generic_type in crates/ruff_python_stdlib/src/typing.rs. frozenset is a generic type.
  3. Manually add frozendict to is_immutable_generic_type and is_immutable_return_type in crates/ruff_python_stdlib/src/typing.rs
  4. Manually updates to scripts/generate_builtin_modules.py: use uv to invoke Python rather than relying on many different Python versions all being on PATH, drop support for Python 3.7 from the script (it can't be installed using uv), and apply various other simplifications.
  5. Regenerate is_builtin_module in crates/ruff_python_stdlib/src/sys/builtin_modules.rs following the changes made in (4). Note that switching to uv-managed Python installs (PBS) appears to mean that quite a few more stdlib modules are recognised as being builtin modules, which is interesting.

I also ran scripts/generate_known_standard_library.py, but it didn't make any changes to the Rust function generated by that script.

Test Plan

cargo test

@AlexWaygood AlexWaygood force-pushed the regenerate-ruff-python-stdlib branch from 1e45548 to fb8a44d Compare May 20, 2026 12:18
@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot Bot commented May 20, 2026

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

@AlexWaygood AlexWaygood force-pushed the regenerate-ruff-python-stdlib branch 2 times, most recently from a4ef0fd to a879468 Compare May 20, 2026 12:43
@AlexWaygood AlexWaygood marked this pull request as ready for review May 20, 2026 12:45
@AlexWaygood AlexWaygood requested a review from charliermarsh May 20, 2026 12:45
Copy link
Copy Markdown
Member

@charliermarsh charliermarsh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! Much better than my #25251 change.

@astral-sh-bot
Copy link
Copy Markdown

astral-sh-bot Bot commented May 20, 2026

ecosystem-analyzer results

No diagnostic changes detected ✅

Large timing changes:

Project Old Time New Time Change
pandas-stubs 11.09s 18.59s +68%

Full report with detailed diff (timing results)

@AlexWaygood AlexWaygood force-pushed the regenerate-ruff-python-stdlib branch from a879468 to 97ea2b6 Compare May 20, 2026 13:09
@AlexWaygood AlexWaygood force-pushed the regenerate-ruff-python-stdlib branch from 97ea2b6 to 88d291a Compare May 20, 2026 13:12
# seemingly ignoring `Diff.__iter__`. Seems like maybe a bug, but
# pyright and mypy both do the same.
diff_lines = cast(list[str], list(diff))
diff_lines = list(diff)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't really pretend I understand why this cast is no longer necessary with these changes, but then again, according to the TODO comment, we never really understood why it was previously necessary, so... ours not to reason why

@AlexWaygood AlexWaygood merged commit bd2d6f6 into main May 20, 2026
50 checks passed
@AlexWaygood AlexWaygood deleted the regenerate-ruff-python-stdlib branch May 20, 2026 13:19
thejchap pushed a commit to thejchap/ruff that referenced this pull request May 23, 2026
## Summary

1. Manually update various functions in
`crates/ruff_python_stdlib/src/builtins.rs` to reflect new APIs added in
Python 3.15.
2. Manually remove the incorrect inclusion of `frozenset` from
`is_immutable_non_generic_type` in
`crates/ruff_python_stdlib/src/typing.rs`. `frozenset` is a generic
type.
3. Manually add `frozendict` to `is_immutable_generic_type` and
`is_immutable_return_type` in `crates/ruff_python_stdlib/src/typing.rs`
4. Manually updates to `scripts/generate_builtin_modules.py`: use uv to
invoke Python rather than relying on many different Python versions all
being on `PATH`, drop support for Python 3.7 from the script (it can't
be installed using uv), and apply various other simplifications.
5. Regenerate `is_builtin_module` in
`crates/ruff_python_stdlib/src/sys/builtin_modules.rs` following the
changes made in (4). Note that switching to uv-managed Python installs
(PBS) appears to mean that quite a few more stdlib modules are
recognised as being builtin modules, which is interesting.

I also ran `scripts/generate_known_standard_library.py`, but it didn't
make any changes to the Rust function generated by that script.

## Test Plan

`cargo test`
anishgirianish pushed a commit to anishgirianish/ruff that referenced this pull request May 28, 2026
## Summary

1. Manually update various functions in
`crates/ruff_python_stdlib/src/builtins.rs` to reflect new APIs added in
Python 3.15.
2. Manually remove the incorrect inclusion of `frozenset` from
`is_immutable_non_generic_type` in
`crates/ruff_python_stdlib/src/typing.rs`. `frozenset` is a generic
type.
3. Manually add `frozendict` to `is_immutable_generic_type` and
`is_immutable_return_type` in `crates/ruff_python_stdlib/src/typing.rs`
4. Manually updates to `scripts/generate_builtin_modules.py`: use uv to
invoke Python rather than relying on many different Python versions all
being on `PATH`, drop support for Python 3.7 from the script (it can't
be installed using uv), and apply various other simplifications.
5. Regenerate `is_builtin_module` in
`crates/ruff_python_stdlib/src/sys/builtin_modules.rs` following the
changes made in (4). Note that switching to uv-managed Python installs
(PBS) appears to mean that quite a few more stdlib modules are
recognised as being builtin modules, which is interesting.

I also ran `scripts/generate_known_standard_library.py`, but it didn't
make any changes to the Rust function generated by that script.

## Test Plan

`cargo test`
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