mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-05-06 21:43:59 +08:00
Clean up deprecated ast.Constant aliases (#14397)
Add `__new__`, remove fields, mark deprecated `Constant` fields as such.
This commit is contained in:
@@ -163,11 +163,7 @@ tkinter.tix.TkVersion
|
||||
# because it's not an ABC that makes any sense and was deprecated in 3.12
|
||||
_collections_abc.ByteString
|
||||
|
||||
ast.Bytes.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
|
||||
ast.Ellipsis.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
|
||||
ast.NameConstant.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
|
||||
ast.Num.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
|
||||
ast.Str.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
|
||||
ast.Ellipsis.__new__ # Implementation has *args, but shouldn't allow any
|
||||
|
||||
_?hashlib.scrypt # Raises TypeError if salt, n, r or p are None
|
||||
|
||||
|
||||
@@ -126,11 +126,7 @@ tkinter.tix.TkVersion
|
||||
# because it's not an ABC that makes any sense and was deprecated in 3.12
|
||||
_collections_abc.ByteString
|
||||
|
||||
ast.Bytes.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
|
||||
ast.Ellipsis.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
|
||||
ast.NameConstant.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
|
||||
ast.Num.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
|
||||
ast.Str.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
|
||||
ast.Ellipsis.__new__ # Implementation has *args, but shouldn't allow any
|
||||
|
||||
_?hashlib.scrypt # Raises TypeError if salt, n, r or p are None
|
||||
|
||||
|
||||
@@ -111,11 +111,7 @@ tkinter.tix.TkVersion
|
||||
# because it's not an ABC that makes any sense and was deprecated in 3.12
|
||||
_collections_abc.ByteString
|
||||
|
||||
ast.Bytes.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
|
||||
ast.Ellipsis.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
|
||||
ast.NameConstant.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
|
||||
ast.Num.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
|
||||
ast.Str.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
|
||||
ast.Ellipsis.__new__ # Implementation has *args, but shouldn't allow any
|
||||
|
||||
_?hashlib.scrypt # Raises TypeError if salt, n, r or p are None
|
||||
|
||||
|
||||
@@ -72,11 +72,7 @@ typing(_extensions)?\.IO\.writelines
|
||||
# because it's not an ABC that makes any sense and was deprecated in 3.12
|
||||
_collections_abc.ByteString
|
||||
|
||||
ast.Bytes.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
|
||||
ast.Ellipsis.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
|
||||
ast.NameConstant.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
|
||||
ast.Num.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
|
||||
ast.Str.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
|
||||
ast.Ellipsis.__new__ # Implementation has *args, but shouldn't allow any
|
||||
|
||||
_?hashlib.scrypt # Raises TypeError if salt, n, r or p are None
|
||||
|
||||
|
||||
@@ -110,11 +110,7 @@ tkinter.tix.TkVersion
|
||||
# because it's not an ABC that makes any sense and was deprecated in 3.12
|
||||
_collections_abc.ByteString
|
||||
|
||||
ast.Bytes.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
|
||||
ast.Ellipsis.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
|
||||
ast.NameConstant.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
|
||||
ast.Num.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
|
||||
ast.Str.__new__ # runtime is *args, **kwargs due to a wrapper, but we have more accurate signatures in the stubs
|
||||
ast.Ellipsis.__new__ # Implementation has *args, but shouldn't allow any
|
||||
|
||||
_?hashlib.scrypt # Raises TypeError if salt, n, r or p are None
|
||||
|
||||
|
||||
+17
-13
@@ -1096,8 +1096,16 @@ class Constant(expr):
|
||||
kind: str | None
|
||||
if sys.version_info < (3, 14):
|
||||
# Aliases for value, for backwards compatibility
|
||||
s: _ConstantValue
|
||||
n: _ConstantValue
|
||||
@deprecated("Will be removed in Python 3.14; use value instead")
|
||||
@property
|
||||
def n(self) -> _ConstantValue: ...
|
||||
@n.setter
|
||||
def n(self, value: _ConstantValue) -> None: ...
|
||||
@deprecated("Will be removed in Python 3.14; use value instead")
|
||||
@property
|
||||
def s(self) -> _ConstantValue: ...
|
||||
@s.setter
|
||||
def s(self, value: _ConstantValue) -> None: ...
|
||||
|
||||
def __init__(self, value: _ConstantValue, kind: str | None = None, **kwargs: Unpack[_Attributes]) -> None: ...
|
||||
|
||||
@@ -1696,27 +1704,23 @@ class _ABC(type):
|
||||
if sys.version_info < (3, 14):
|
||||
@deprecated("Replaced by ast.Constant; removed in Python 3.14")
|
||||
class Num(Constant, metaclass=_ABC):
|
||||
value: int | float | complex
|
||||
# Aliases for value, for backwards compatibility
|
||||
n: int | float | complex
|
||||
def __new__(cls, n: complex, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore[misc] # pyright: ignore[reportInconsistentConstructor]
|
||||
|
||||
@deprecated("Replaced by ast.Constant; removed in Python 3.14")
|
||||
class Str(Constant, metaclass=_ABC):
|
||||
value: str
|
||||
# Aliases for value, for backwards compatibility
|
||||
s: str
|
||||
def __new__(cls, s: str, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore[misc] # pyright: ignore[reportInconsistentConstructor]
|
||||
|
||||
@deprecated("Replaced by ast.Constant; removed in Python 3.14")
|
||||
class Bytes(Constant, metaclass=_ABC):
|
||||
value: bytes
|
||||
# Aliases for value, for backwards compatibility
|
||||
s: bytes
|
||||
def __new__(cls, s: bytes, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore[misc] # pyright: ignore[reportInconsistentConstructor]
|
||||
|
||||
@deprecated("Replaced by ast.Constant; removed in Python 3.14")
|
||||
class NameConstant(Constant, metaclass=_ABC): ...
|
||||
class NameConstant(Constant, metaclass=_ABC):
|
||||
def __new__(cls, value: _ConstantValue, kind: str | None, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore[misc] # pyright: ignore[reportInconsistentConstructor]
|
||||
|
||||
@deprecated("Replaced by ast.Constant; removed in Python 3.14")
|
||||
class Ellipsis(Constant, metaclass=_ABC): ...
|
||||
class Ellipsis(Constant, metaclass=_ABC):
|
||||
def __new__(cls, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore[misc] # pyright: ignore[reportInconsistentConstructor]
|
||||
|
||||
# everything below here is defined in ast.py
|
||||
|
||||
|
||||
Reference in New Issue
Block a user