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
Prev Previous commit
Next Next commit
Remove fields from deprecated classes
Add @deprecated marker to deprecated `Constant` attributes
  • Loading branch information
srittau committed Jul 11, 2025
commit 3c59c0ce8cf56245a0fcb52a9362c253a559b591
17 changes: 6 additions & 11 deletions stdlib/ast.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1096,8 +1096,12 @@
kind: str | None
if sys.version_info < (3, 14):
# Aliases for value, for backwards compatibility
s: _ConstantValue
n: _ConstantValue
@deprecated("Attribute n is deprecated and will be removed in Python 3.14; use value instead")
@property
def n(self) -> _ConstantValue: ...
@deprecated("Attribute s is deprecated and will be removed in Python 3.14; use value instead")
@property
def s(self) -> _ConstantValue: ...

def __init__(self, value: _ConstantValue, kind: str | None = None, **kwargs: Unpack[_Attributes]) -> None: ...

Expand Down Expand Up @@ -1696,24 +1700,15 @@
if sys.version_info < (3, 14):
@deprecated("Replaced by ast.Constant; removed in Python 3.14")
class Num(Constant, metaclass=_ABC):
def __new__(cls, *args, **kwargs) -> Constant: ... # type: ignore[misc]

Check failure on line 1703 in stdlib/ast.pyi

View workflow job for this annotation

GitHub Actions / pyright: Run test cases (Linux, 3.13)

Type annotation is missing for parameter "kwargs" (reportMissingParameterType)

Check failure on line 1703 in stdlib/ast.pyi

View workflow job for this annotation

GitHub Actions / pyright: Run test cases (Linux, 3.13)

Type of parameter "kwargs" is unknown (reportUnknownParameterType)

Check failure on line 1703 in stdlib/ast.pyi

View workflow job for this annotation

GitHub Actions / pyright: Run test cases (Linux, 3.13)

Type annotation is missing for parameter "args" (reportMissingParameterType)

Check failure on line 1703 in stdlib/ast.pyi

View workflow job for this annotation

GitHub Actions / pyright: Run test cases (Linux, 3.13)

Type of parameter "args" is unknown (reportUnknownParameterType)
value: int | float | complex
# Aliases for value, for backwards compatibility
n: int | float | complex

@deprecated("Replaced by ast.Constant; removed in Python 3.14")
class Str(Constant, metaclass=_ABC):
def __new__(cls, *args, **kwargs) -> Constant: ... # type: ignore[misc]

Check failure on line 1707 in stdlib/ast.pyi

View workflow job for this annotation

GitHub Actions / pyright: Run test cases (Linux, 3.13)

Type annotation is missing for parameter "kwargs" (reportMissingParameterType)

Check failure on line 1707 in stdlib/ast.pyi

View workflow job for this annotation

GitHub Actions / pyright: Run test cases (Linux, 3.13)

Type of parameter "kwargs" is unknown (reportUnknownParameterType)

Check failure on line 1707 in stdlib/ast.pyi

View workflow job for this annotation

GitHub Actions / pyright: Run test cases (Linux, 3.13)

Type annotation is missing for parameter "args" (reportMissingParameterType)

Check failure on line 1707 in stdlib/ast.pyi

View workflow job for this annotation

GitHub Actions / pyright: Run test cases (Linux, 3.13)

Type of parameter "args" is unknown (reportUnknownParameterType)
value: str
# Aliases for value, for backwards compatibility
s: str

@deprecated("Replaced by ast.Constant; removed in Python 3.14")
class Bytes(Constant, metaclass=_ABC):
def __new__(cls, *args, **kwargs) -> Constant: ... # type: ignore[misc]

Check failure on line 1711 in stdlib/ast.pyi

View workflow job for this annotation

GitHub Actions / pyright: Run test cases (Linux, 3.13)

Type annotation is missing for parameter "args" (reportMissingParameterType)

Check failure on line 1711 in stdlib/ast.pyi

View workflow job for this annotation

GitHub Actions / pyright: Run test cases (Linux, 3.13)

Type of parameter "args" is unknown (reportUnknownParameterType)
value: bytes
# Aliases for value, for backwards compatibility
s: bytes

@deprecated("Replaced by ast.Constant; removed in Python 3.14")
class NameConstant(Constant, metaclass=_ABC):
Expand Down
Loading
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