Skip to content

Add __new__ to old ast.Constant aliases #14397

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

Merged
merged 16 commits into from
Jul 11, 2025
Merged

Conversation

srittau
Copy link
Collaborator

@srittau srittau commented Jul 11, 2025

This aligns the old constant classes closer to the actual implementation. It's not perfect, as it doesn't replicate the __instancecheck__ and doesn't replicate the fact that theoretical sub-classes of the old constant classes are still possible and don't get replaced with Constant.

This comment has been minimized.

This comment has been minimized.

@srittau
Copy link
Collaborator Author

srittau commented Jul 11, 2025

The only primer hit is (as expected) in a piece of code that won't work on Python 3.14, but can actually be simplified.

@srittau srittau marked this pull request as ready for review July 11, 2025 11:39
@srittau
Copy link
Collaborator Author

srittau commented Jul 11, 2025

This aligns the old constant classes closer to the actual implementation. It's not perfect, as it doesn't replicate the __instancecheck__ and doesn't replicate the fact that theoretical sub-classes of the old constant classes are still possible and don't get replaced with Constant.

That said, the minimal primer fallout and the fact that these are deprecated classes, so no new code will use them, indicates that this is not a problem.

This comment has been minimized.

Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

spack (https://github.com/spack/spack)
+ lib/spack/spack/cmd/style.py:666: error: Incompatible types in assignment (expression has type "str | bytes | int | float | complex | EllipsisType | None", variable has type "str")  [assignment]

@srittau srittau merged commit d5af6be into python:main Jul 11, 2025
64 checks passed
@srittau srittau deleted the deprecated-ast branch July 11, 2025 12:59
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
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy