From 61af05e9f49046f5725b5bd282ace86c55adae62 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Fri, 11 Jul 2025 12:12:29 +0200 Subject: [PATCH 01/16] Add __new__ to old ast.Constant aliases --- stdlib/ast.pyi | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/stdlib/ast.pyi b/stdlib/ast.pyi index 3f45ba581c60..641c208bef31 100644 --- a/stdlib/ast.pyi +++ b/stdlib/ast.pyi @@ -1696,27 +1696,32 @@ class _ABC(type): 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: ... 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: ... 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: ... 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): ... + class NameConstant(Constant, metaclass=_ABC): + def __new__(cls, *args, **kwargs) -> Constant: ... @deprecated("Replaced by ast.Constant; removed in Python 3.14") - class Ellipsis(Constant, metaclass=_ABC): ... + class Ellipsis(Constant, metaclass=_ABC): + def __new__(cls, *args, **kwargs) -> Constant: ... # everything below here is defined in ast.py From 2c52b43c4f5feb4f98071b9314535e6aa10e5d92 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Fri, 11 Jul 2025 12:15:20 +0200 Subject: [PATCH 02/16] Add type: ignore --- stdlib/ast.pyi | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/stdlib/ast.pyi b/stdlib/ast.pyi index 641c208bef31..c3c826664989 100644 --- a/stdlib/ast.pyi +++ b/stdlib/ast.pyi @@ -1696,32 +1696,32 @@ class _ABC(type): 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: ... + def __new__(cls, *args, **kwargs) -> Constant: ... # type: ignore[misc] 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: ... + def __new__(cls, *args, **kwargs) -> Constant: ... # type: ignore[misc] 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: ... + def __new__(cls, *args, **kwargs) -> Constant: ... # type: ignore[misc] 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): - def __new__(cls, *args, **kwargs) -> Constant: ... + def __new__(cls, *args, **kwargs) -> Constant: ... # type: ignore[misc] @deprecated("Replaced by ast.Constant; removed in Python 3.14") class Ellipsis(Constant, metaclass=_ABC): - def __new__(cls, *args, **kwargs) -> Constant: ... + def __new__(cls, *args, **kwargs) -> Constant: ... # type: ignore[misc] # everything below here is defined in ast.py From b813e7e3bce3ebc6f3a1cbddbd2c50bcd02b62da Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Fri, 11 Jul 2025 12:21:20 +0200 Subject: [PATCH 03/16] Remove allowlist entries --- stdlib/@tests/stubtest_allowlists/py310.txt | 6 ------ stdlib/@tests/stubtest_allowlists/py311.txt | 6 ------ stdlib/@tests/stubtest_allowlists/py312.txt | 6 ------ stdlib/@tests/stubtest_allowlists/py313.txt | 6 ------ stdlib/@tests/stubtest_allowlists/py39.txt | 6 ------ 5 files changed, 30 deletions(-) diff --git a/stdlib/@tests/stubtest_allowlists/py310.txt b/stdlib/@tests/stubtest_allowlists/py310.txt index d2030f8713be..65046480b39d 100644 --- a/stdlib/@tests/stubtest_allowlists/py310.txt +++ b/stdlib/@tests/stubtest_allowlists/py310.txt @@ -163,12 +163,6 @@ 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 - _?hashlib.scrypt # Raises TypeError if salt, n, r or p are None importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments. diff --git a/stdlib/@tests/stubtest_allowlists/py311.txt b/stdlib/@tests/stubtest_allowlists/py311.txt index e4c26ccfcf1f..c6926b8bfb60 100644 --- a/stdlib/@tests/stubtest_allowlists/py311.txt +++ b/stdlib/@tests/stubtest_allowlists/py311.txt @@ -126,12 +126,6 @@ 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 - _?hashlib.scrypt # Raises TypeError if salt, n, r or p are None importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments. diff --git a/stdlib/@tests/stubtest_allowlists/py312.txt b/stdlib/@tests/stubtest_allowlists/py312.txt index 685a1bf41e75..22ee338adf54 100644 --- a/stdlib/@tests/stubtest_allowlists/py312.txt +++ b/stdlib/@tests/stubtest_allowlists/py312.txt @@ -111,12 +111,6 @@ 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 - _?hashlib.scrypt # Raises TypeError if salt, n, r or p are None importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments. diff --git a/stdlib/@tests/stubtest_allowlists/py313.txt b/stdlib/@tests/stubtest_allowlists/py313.txt index 282b91348758..b6cbcf9a5eee 100644 --- a/stdlib/@tests/stubtest_allowlists/py313.txt +++ b/stdlib/@tests/stubtest_allowlists/py313.txt @@ -72,12 +72,6 @@ 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 - _?hashlib.scrypt # Raises TypeError if salt, n, r or p are None importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments. diff --git a/stdlib/@tests/stubtest_allowlists/py39.txt b/stdlib/@tests/stubtest_allowlists/py39.txt index 37c1ec2ad171..760b73c4df71 100644 --- a/stdlib/@tests/stubtest_allowlists/py39.txt +++ b/stdlib/@tests/stubtest_allowlists/py39.txt @@ -110,12 +110,6 @@ 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 - _?hashlib.scrypt # Raises TypeError if salt, n, r or p are None importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments. From 3c59c0ce8cf56245a0fcb52a9362c253a559b591 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Fri, 11 Jul 2025 12:21:27 +0200 Subject: [PATCH 04/16] Remove fields from deprecated classes Add @deprecated marker to deprecated `Constant` attributes --- stdlib/ast.pyi | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/stdlib/ast.pyi b/stdlib/ast.pyi index c3c826664989..a0930fd36e78 100644 --- a/stdlib/ast.pyi +++ b/stdlib/ast.pyi @@ -1096,8 +1096,12 @@ class Constant(expr): 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: ... @@ -1697,23 +1701,14 @@ 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] - 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] - 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] - 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): From 503df8a03c55307af9ce9d1d6f5b6764558f058c Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Fri, 11 Jul 2025 12:41:21 +0200 Subject: [PATCH 05/16] Annotate __new__ arguments --- stdlib/ast.pyi | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/stdlib/ast.pyi b/stdlib/ast.pyi index a0930fd36e78..67a4964bc2f6 100644 --- a/stdlib/ast.pyi +++ b/stdlib/ast.pyi @@ -1700,23 +1700,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): - def __new__(cls, *args, **kwargs) -> Constant: ... # type: ignore[misc] + def __new__(cls, n: int | float | complex, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore[misc] @deprecated("Replaced by ast.Constant; removed in Python 3.14") class Str(Constant, metaclass=_ABC): - def __new__(cls, *args, **kwargs) -> Constant: ... # type: ignore[misc] + def __new__(cls, s: str, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore[misc] @deprecated("Replaced by ast.Constant; removed in Python 3.14") class Bytes(Constant, metaclass=_ABC): - def __new__(cls, *args, **kwargs) -> Constant: ... # type: ignore[misc] + def __new__(cls, s: bytes, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore[misc] @deprecated("Replaced by ast.Constant; removed in Python 3.14") class NameConstant(Constant, metaclass=_ABC): - def __new__(cls, *args, **kwargs) -> Constant: ... # type: ignore[misc] + def __new__(cls, value: _ConstantValue, kind: str | None, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore[misc] @deprecated("Replaced by ast.Constant; removed in Python 3.14") class Ellipsis(Constant, metaclass=_ABC): - def __new__(cls, *args, **kwargs) -> Constant: ... # type: ignore[misc] + def __new__(cls, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore[misc] # everything below here is defined in ast.py From 96562289c2acd772fa877c272cb92fc120245bc3 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Fri, 11 Jul 2025 12:46:49 +0200 Subject: [PATCH 06/16] Add ast.Ellipsis.__new__ to allowlist --- stdlib/@tests/stubtest_allowlists/py310.txt | 2 ++ stdlib/@tests/stubtest_allowlists/py311.txt | 2 ++ stdlib/@tests/stubtest_allowlists/py312.txt | 2 ++ stdlib/@tests/stubtest_allowlists/py313.txt | 2 ++ stdlib/@tests/stubtest_allowlists/py39.txt | 2 ++ 5 files changed, 10 insertions(+) diff --git a/stdlib/@tests/stubtest_allowlists/py310.txt b/stdlib/@tests/stubtest_allowlists/py310.txt index 65046480b39d..556478e4d2c2 100644 --- a/stdlib/@tests/stubtest_allowlists/py310.txt +++ b/stdlib/@tests/stubtest_allowlists/py310.txt @@ -163,6 +163,8 @@ tkinter.tix.TkVersion # because it's not an ABC that makes any sense and was deprecated in 3.12 _collections_abc.ByteString +ast.Ellipsis.__new__ # Implementation has *args, but shouldn't allow any + _?hashlib.scrypt # Raises TypeError if salt, n, r or p are None importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments. diff --git a/stdlib/@tests/stubtest_allowlists/py311.txt b/stdlib/@tests/stubtest_allowlists/py311.txt index c6926b8bfb60..a99e1220bfc0 100644 --- a/stdlib/@tests/stubtest_allowlists/py311.txt +++ b/stdlib/@tests/stubtest_allowlists/py311.txt @@ -126,6 +126,8 @@ tkinter.tix.TkVersion # because it's not an ABC that makes any sense and was deprecated in 3.12 _collections_abc.ByteString +ast.Ellipsis.__new__ # Implementation has *args, but shouldn't allow any + _?hashlib.scrypt # Raises TypeError if salt, n, r or p are None importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments. diff --git a/stdlib/@tests/stubtest_allowlists/py312.txt b/stdlib/@tests/stubtest_allowlists/py312.txt index 22ee338adf54..c5faf72eeed7 100644 --- a/stdlib/@tests/stubtest_allowlists/py312.txt +++ b/stdlib/@tests/stubtest_allowlists/py312.txt @@ -111,6 +111,8 @@ tkinter.tix.TkVersion # because it's not an ABC that makes any sense and was deprecated in 3.12 _collections_abc.ByteString +ast.Ellipsis.__new__ # Implementation has *args, but shouldn't allow any + _?hashlib.scrypt # Raises TypeError if salt, n, r or p are None importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments. diff --git a/stdlib/@tests/stubtest_allowlists/py313.txt b/stdlib/@tests/stubtest_allowlists/py313.txt index b6cbcf9a5eee..5645abe9fcbd 100644 --- a/stdlib/@tests/stubtest_allowlists/py313.txt +++ b/stdlib/@tests/stubtest_allowlists/py313.txt @@ -72,6 +72,8 @@ typing(_extensions)?\.IO\.writelines # because it's not an ABC that makes any sense and was deprecated in 3.12 _collections_abc.ByteString +ast.Ellipsis.__new__ # Implementation has *args, but shouldn't allow any + _?hashlib.scrypt # Raises TypeError if salt, n, r or p are None importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments. diff --git a/stdlib/@tests/stubtest_allowlists/py39.txt b/stdlib/@tests/stubtest_allowlists/py39.txt index 760b73c4df71..8c7de0f3a871 100644 --- a/stdlib/@tests/stubtest_allowlists/py39.txt +++ b/stdlib/@tests/stubtest_allowlists/py39.txt @@ -110,6 +110,8 @@ tkinter.tix.TkVersion # because it's not an ABC that makes any sense and was deprecated in 3.12 _collections_abc.ByteString +ast.Ellipsis.__new__ # Implementation has *args, but shouldn't allow any + _?hashlib.scrypt # Raises TypeError if salt, n, r or p are None importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments. From 4948960878d44b7b5362ef4376357423cfb2446b Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Fri, 11 Jul 2025 12:50:01 +0200 Subject: [PATCH 07/16] Revert "Add ast.Ellipsis.__new__ to allowlist" This reverts commit 96562289c2acd772fa877c272cb92fc120245bc3. --- stdlib/@tests/stubtest_allowlists/py310.txt | 2 -- stdlib/@tests/stubtest_allowlists/py311.txt | 2 -- stdlib/@tests/stubtest_allowlists/py312.txt | 2 -- stdlib/@tests/stubtest_allowlists/py313.txt | 2 -- stdlib/@tests/stubtest_allowlists/py39.txt | 2 -- 5 files changed, 10 deletions(-) diff --git a/stdlib/@tests/stubtest_allowlists/py310.txt b/stdlib/@tests/stubtest_allowlists/py310.txt index 556478e4d2c2..65046480b39d 100644 --- a/stdlib/@tests/stubtest_allowlists/py310.txt +++ b/stdlib/@tests/stubtest_allowlists/py310.txt @@ -163,8 +163,6 @@ tkinter.tix.TkVersion # because it's not an ABC that makes any sense and was deprecated in 3.12 _collections_abc.ByteString -ast.Ellipsis.__new__ # Implementation has *args, but shouldn't allow any - _?hashlib.scrypt # Raises TypeError if salt, n, r or p are None importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments. diff --git a/stdlib/@tests/stubtest_allowlists/py311.txt b/stdlib/@tests/stubtest_allowlists/py311.txt index a99e1220bfc0..c6926b8bfb60 100644 --- a/stdlib/@tests/stubtest_allowlists/py311.txt +++ b/stdlib/@tests/stubtest_allowlists/py311.txt @@ -126,8 +126,6 @@ tkinter.tix.TkVersion # because it's not an ABC that makes any sense and was deprecated in 3.12 _collections_abc.ByteString -ast.Ellipsis.__new__ # Implementation has *args, but shouldn't allow any - _?hashlib.scrypt # Raises TypeError if salt, n, r or p are None importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments. diff --git a/stdlib/@tests/stubtest_allowlists/py312.txt b/stdlib/@tests/stubtest_allowlists/py312.txt index c5faf72eeed7..22ee338adf54 100644 --- a/stdlib/@tests/stubtest_allowlists/py312.txt +++ b/stdlib/@tests/stubtest_allowlists/py312.txt @@ -111,8 +111,6 @@ tkinter.tix.TkVersion # because it's not an ABC that makes any sense and was deprecated in 3.12 _collections_abc.ByteString -ast.Ellipsis.__new__ # Implementation has *args, but shouldn't allow any - _?hashlib.scrypt # Raises TypeError if salt, n, r or p are None importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments. diff --git a/stdlib/@tests/stubtest_allowlists/py313.txt b/stdlib/@tests/stubtest_allowlists/py313.txt index 5645abe9fcbd..b6cbcf9a5eee 100644 --- a/stdlib/@tests/stubtest_allowlists/py313.txt +++ b/stdlib/@tests/stubtest_allowlists/py313.txt @@ -72,8 +72,6 @@ typing(_extensions)?\.IO\.writelines # because it's not an ABC that makes any sense and was deprecated in 3.12 _collections_abc.ByteString -ast.Ellipsis.__new__ # Implementation has *args, but shouldn't allow any - _?hashlib.scrypt # Raises TypeError if salt, n, r or p are None importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments. diff --git a/stdlib/@tests/stubtest_allowlists/py39.txt b/stdlib/@tests/stubtest_allowlists/py39.txt index 8c7de0f3a871..760b73c4df71 100644 --- a/stdlib/@tests/stubtest_allowlists/py39.txt +++ b/stdlib/@tests/stubtest_allowlists/py39.txt @@ -110,8 +110,6 @@ tkinter.tix.TkVersion # because it's not an ABC that makes any sense and was deprecated in 3.12 _collections_abc.ByteString -ast.Ellipsis.__new__ # Implementation has *args, but shouldn't allow any - _?hashlib.scrypt # Raises TypeError if salt, n, r or p are None importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments. From 0f22d0c5d8395876c719227eefb65308cfab4cf9 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Fri, 11 Jul 2025 12:51:35 +0200 Subject: [PATCH 08/16] Broaden type ignores --- stdlib/ast.pyi | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/stdlib/ast.pyi b/stdlib/ast.pyi index 67a4964bc2f6..a6a9298bcf76 100644 --- a/stdlib/ast.pyi +++ b/stdlib/ast.pyi @@ -1700,23 +1700,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): - def __new__(cls, n: int | float | complex, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore[misc] + def __new__(cls, n: int | float | complex, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore @deprecated("Replaced by ast.Constant; removed in Python 3.14") class Str(Constant, metaclass=_ABC): - def __new__(cls, s: str, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore[misc] + def __new__(cls, s: str, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore @deprecated("Replaced by ast.Constant; removed in Python 3.14") class Bytes(Constant, metaclass=_ABC): - def __new__(cls, s: bytes, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore[misc] + def __new__(cls, s: bytes, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore @deprecated("Replaced by ast.Constant; removed in Python 3.14") class NameConstant(Constant, metaclass=_ABC): - def __new__(cls, value: _ConstantValue, kind: str | None, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore[misc] + def __new__(cls, value: _ConstantValue, kind: str | None, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore @deprecated("Replaced by ast.Constant; removed in Python 3.14") class Ellipsis(Constant, metaclass=_ABC): - def __new__(cls, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore[misc] + def __new__(cls, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore # everything below here is defined in ast.py From 076515a64c10d8ddf36df9a2f8b33ccafed1f48b Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Fri, 11 Jul 2025 12:53:34 +0200 Subject: [PATCH 09/16] Reapply "Add ast.Ellipsis.__new__ to allowlist" This reverts commit 4948960878d44b7b5362ef4376357423cfb2446b. --- stdlib/@tests/stubtest_allowlists/py310.txt | 2 ++ stdlib/@tests/stubtest_allowlists/py311.txt | 2 ++ stdlib/@tests/stubtest_allowlists/py312.txt | 2 ++ stdlib/@tests/stubtest_allowlists/py313.txt | 2 ++ stdlib/@tests/stubtest_allowlists/py39.txt | 2 ++ 5 files changed, 10 insertions(+) diff --git a/stdlib/@tests/stubtest_allowlists/py310.txt b/stdlib/@tests/stubtest_allowlists/py310.txt index 65046480b39d..556478e4d2c2 100644 --- a/stdlib/@tests/stubtest_allowlists/py310.txt +++ b/stdlib/@tests/stubtest_allowlists/py310.txt @@ -163,6 +163,8 @@ tkinter.tix.TkVersion # because it's not an ABC that makes any sense and was deprecated in 3.12 _collections_abc.ByteString +ast.Ellipsis.__new__ # Implementation has *args, but shouldn't allow any + _?hashlib.scrypt # Raises TypeError if salt, n, r or p are None importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments. diff --git a/stdlib/@tests/stubtest_allowlists/py311.txt b/stdlib/@tests/stubtest_allowlists/py311.txt index c6926b8bfb60..a99e1220bfc0 100644 --- a/stdlib/@tests/stubtest_allowlists/py311.txt +++ b/stdlib/@tests/stubtest_allowlists/py311.txt @@ -126,6 +126,8 @@ tkinter.tix.TkVersion # because it's not an ABC that makes any sense and was deprecated in 3.12 _collections_abc.ByteString +ast.Ellipsis.__new__ # Implementation has *args, but shouldn't allow any + _?hashlib.scrypt # Raises TypeError if salt, n, r or p are None importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments. diff --git a/stdlib/@tests/stubtest_allowlists/py312.txt b/stdlib/@tests/stubtest_allowlists/py312.txt index 22ee338adf54..c5faf72eeed7 100644 --- a/stdlib/@tests/stubtest_allowlists/py312.txt +++ b/stdlib/@tests/stubtest_allowlists/py312.txt @@ -111,6 +111,8 @@ tkinter.tix.TkVersion # because it's not an ABC that makes any sense and was deprecated in 3.12 _collections_abc.ByteString +ast.Ellipsis.__new__ # Implementation has *args, but shouldn't allow any + _?hashlib.scrypt # Raises TypeError if salt, n, r or p are None importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments. diff --git a/stdlib/@tests/stubtest_allowlists/py313.txt b/stdlib/@tests/stubtest_allowlists/py313.txt index b6cbcf9a5eee..5645abe9fcbd 100644 --- a/stdlib/@tests/stubtest_allowlists/py313.txt +++ b/stdlib/@tests/stubtest_allowlists/py313.txt @@ -72,6 +72,8 @@ typing(_extensions)?\.IO\.writelines # because it's not an ABC that makes any sense and was deprecated in 3.12 _collections_abc.ByteString +ast.Ellipsis.__new__ # Implementation has *args, but shouldn't allow any + _?hashlib.scrypt # Raises TypeError if salt, n, r or p are None importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments. diff --git a/stdlib/@tests/stubtest_allowlists/py39.txt b/stdlib/@tests/stubtest_allowlists/py39.txt index 760b73c4df71..8c7de0f3a871 100644 --- a/stdlib/@tests/stubtest_allowlists/py39.txt +++ b/stdlib/@tests/stubtest_allowlists/py39.txt @@ -110,6 +110,8 @@ tkinter.tix.TkVersion # because it's not an ABC that makes any sense and was deprecated in 3.12 _collections_abc.ByteString +ast.Ellipsis.__new__ # Implementation has *args, but shouldn't allow any + _?hashlib.scrypt # Raises TypeError if salt, n, r or p are None importlib.abc.Traversable.open # Problematic protocol signature at runtime, see source code comments. From bdb9adcf48a132e2b525e0b0533d06bd60df4809 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Fri, 11 Jul 2025 12:58:00 +0200 Subject: [PATCH 10/16] pyright ignore --- stdlib/ast.pyi | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/stdlib/ast.pyi b/stdlib/ast.pyi index a6a9298bcf76..8bfbbe91d29a 100644 --- a/stdlib/ast.pyi +++ b/stdlib/ast.pyi @@ -1700,23 +1700,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): - def __new__(cls, n: int | float | complex, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore + def __new__(cls, n: int | float | 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): - def __new__(cls, s: str, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore + 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): - def __new__(cls, s: bytes, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore + 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): - def __new__(cls, value: _ConstantValue, kind: str | None, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore + 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): - def __new__(cls, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore + def __new__(cls, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore[misc # pyright: ignore[reportInconsistentConstructor]] # everything below here is defined in ast.py From e4d190a1229ac9e834dd106f356f603ab0002187 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Fri, 11 Jul 2025 13:01:15 +0200 Subject: [PATCH 11/16] fix --- stdlib/ast.pyi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stdlib/ast.pyi b/stdlib/ast.pyi index 8bfbbe91d29a..52c541e7c65f 100644 --- a/stdlib/ast.pyi +++ b/stdlib/ast.pyi @@ -1704,19 +1704,19 @@ if sys.version_info < (3, 14): @deprecated("Replaced by ast.Constant; removed in Python 3.14") class Str(Constant, metaclass=_ABC): - def __new__(cls, s: str, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore[misc # pyright: ignore[reportInconsistentConstructor]] + 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): - def __new__(cls, s: bytes, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore[misc # pyright: ignore[reportInconsistentConstructor]] + 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): - def __new__(cls, value: _ConstantValue, kind: str | None, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore[misc # pyright: ignore[reportInconsistentConstructor]] + 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): - def __new__(cls, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore[misc # pyright: ignore[reportInconsistentConstructor]] + def __new__(cls, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore[misc] # pyright: ignore[reportInconsistentConstructor] # everything below here is defined in ast.py From 479e748c169631a40b93ece3e6895c49e708abcc Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Fri, 11 Jul 2025 13:36:33 +0200 Subject: [PATCH 12/16] Fix a linter warning --- stdlib/ast.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/ast.pyi b/stdlib/ast.pyi index 52c541e7c65f..012305645d40 100644 --- a/stdlib/ast.pyi +++ b/stdlib/ast.pyi @@ -1700,7 +1700,7 @@ class _ABC(type): if sys.version_info < (3, 14): @deprecated("Replaced by ast.Constant; removed in Python 3.14") class Num(Constant, metaclass=_ABC): - def __new__(cls, n: int | float | complex, **kwargs: Unpack[_Attributes]) -> Constant: ... # type: ignore[misc] # pyright: ignore[reportInconsistentConstructor] + 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): From aa366835154baaaf10db067bfe32d34edcea56f6 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Fri, 11 Jul 2025 13:36:57 +0200 Subject: [PATCH 13/16] Remove 'deprecated' wording --- stdlib/ast.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/ast.pyi b/stdlib/ast.pyi index 012305645d40..8f8cdf40c582 100644 --- a/stdlib/ast.pyi +++ b/stdlib/ast.pyi @@ -1096,10 +1096,10 @@ class Constant(expr): kind: str | None if sys.version_info < (3, 14): # Aliases for value, for backwards compatibility - @deprecated("Attribute n is deprecated and will be removed in Python 3.14; use value instead") + @deprecated("Attribute n 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") + @deprecated("Attribute s will be removed in Python 3.14; use value instead") @property def s(self) -> _ConstantValue: ... From b1eca026e7c37f7c47702d6cf977e360b2e29f9b Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Fri, 11 Jul 2025 13:41:56 +0200 Subject: [PATCH 14/16] Even shorter deprecation message --- stdlib/ast.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/ast.pyi b/stdlib/ast.pyi index 8f8cdf40c582..3418e9f0f9fd 100644 --- a/stdlib/ast.pyi +++ b/stdlib/ast.pyi @@ -1096,10 +1096,10 @@ class Constant(expr): kind: str | None if sys.version_info < (3, 14): # Aliases for value, for backwards compatibility - @deprecated("Attribute n will be removed in Python 3.14; use value instead") + @deprecated("Will be removed in Python 3.14; use value instead") @property def n(self) -> _ConstantValue: ... - @deprecated("Attribute s will be removed in Python 3.14; use value instead") + @deprecated("Will be removed in Python 3.14; use value instead") @property def s(self) -> _ConstantValue: ... From 4c518cc403c9bf2172d179ba5cf9cb605bead115 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Fri, 11 Jul 2025 14:27:05 +0200 Subject: [PATCH 15/16] Add setters --- stdlib/ast.pyi | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/stdlib/ast.pyi b/stdlib/ast.pyi index 3418e9f0f9fd..b420607afe04 100644 --- a/stdlib/ast.pyi +++ b/stdlib/ast.pyi @@ -1100,8 +1100,14 @@ class Constant(expr): @property def n(self) -> _ConstantValue: ... @deprecated("Will be removed in Python 3.14; use value instead") + @n.setter + def n(self, value: _ConstantValue) -> None: ... + @deprecated("Will be removed in Python 3.14; use value instead") @property def s(self) -> _ConstantValue: ... + @deprecated("Will be removed in Python 3.14; use value instead") + @s.setter + def s(self, value: _ConstantValue) -> None: ... def __init__(self, value: _ConstantValue, kind: str | None = None, **kwargs: Unpack[_Attributes]) -> None: ... From fac6f9a361fd7b034266b2b5e52288258eaf8c0d Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Fri, 11 Jul 2025 14:28:21 +0200 Subject: [PATCH 16/16] fix --- stdlib/ast.pyi | 2 -- 1 file changed, 2 deletions(-) diff --git a/stdlib/ast.pyi b/stdlib/ast.pyi index b420607afe04..33019bc2cc73 100644 --- a/stdlib/ast.pyi +++ b/stdlib/ast.pyi @@ -1099,13 +1099,11 @@ class Constant(expr): @deprecated("Will be removed in Python 3.14; use value instead") @property def n(self) -> _ConstantValue: ... - @deprecated("Will be removed in Python 3.14; use value instead") @n.setter def n(self, value: _ConstantValue) -> None: ... @deprecated("Will be removed in Python 3.14; use value instead") @property def s(self) -> _ConstantValue: ... - @deprecated("Will be removed in Python 3.14; use value instead") @s.setter def s(self, value: _ConstantValue) -> None: ... 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