From a03e5d9c5e2a46ecf83cdab13e3c056f2eb20d50 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 21 Aug 2025 21:09:00 -0700 Subject: [PATCH 1/4] Ran a few stubdefaulter wrong-default --- stdlib/_hashlib.pyi | 28 +++++++++++++--------------- stdlib/builtins.pyi | 2 +- stdlib/distutils/file_util.pyi | 4 ++-- stdlib/gettext.pyi | 10 +++++----- stdlib/tkinter/__init__.pyi | 2 +- 5 files changed, 22 insertions(+), 24 deletions(-) diff --git a/stdlib/_hashlib.pyi b/stdlib/_hashlib.pyi index 8b7ef52cdffd..2254226566ef 100644 --- a/stdlib/_hashlib.pyi +++ b/stdlib/_hashlib.pyi @@ -63,43 +63,41 @@ def hmac_new(key: bytes | bytearray, msg: ReadableBuffer = b"", digestmod: _Dige if sys.version_info >= (3, 13): def new( - name: str, data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None - ) -> HASH: ... - def openssl_md5( - data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None + name: str, data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = b"" ) -> HASH: ... + def openssl_md5(data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = b"") -> HASH: ... def openssl_sha1( - data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None + data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = b"" ) -> HASH: ... def openssl_sha224( - data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None + data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = b"" ) -> HASH: ... def openssl_sha256( - data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None + data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = b"" ) -> HASH: ... def openssl_sha384( - data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None + data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = b"" ) -> HASH: ... def openssl_sha512( - data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None + data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = b"" ) -> HASH: ... def openssl_sha3_224( - data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None + data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = b"" ) -> HASH: ... def openssl_sha3_256( - data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None + data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = b"" ) -> HASH: ... def openssl_sha3_384( - data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None + data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = b"" ) -> HASH: ... def openssl_sha3_512( - data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None + data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = b"" ) -> HASH: ... def openssl_shake_128( - data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None + data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = b"" ) -> HASHXOF: ... def openssl_shake_256( - data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = None + data: ReadableBuffer = b"", *, usedforsecurity: bool = True, string: ReadableBuffer | None = b"" ) -> HASHXOF: ... else: diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index c7ab95482f6b..b4dd9a338dbb 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -1519,7 +1519,7 @@ help: _sitebuiltins._Helper def hex(number: int | SupportsIndex, /) -> str: ... def id(obj: object, /) -> int: ... -def input(prompt: object = "", /) -> str: ... +def input(prompt: object = None, /) -> str: ... @type_check_only class _GetItemIterable(Protocol[_T_co]): def __getitem__(self, i: int, /) -> _T_co: ... diff --git a/stdlib/distutils/file_util.pyi b/stdlib/distutils/file_util.pyi index 873d23ea7e50..c763f91a958d 100644 --- a/stdlib/distutils/file_util.pyi +++ b/stdlib/distutils/file_util.pyi @@ -29,10 +29,10 @@ def copy_file( ) -> tuple[_BytesPathT | bytes, bool]: ... @overload def move_file( - src: StrPath, dst: _StrPathT, verbose: bool | Literal[0, 1] = 0, dry_run: bool | Literal[0, 1] = 0 + src: StrPath, dst: _StrPathT, verbose: bool | Literal[0, 1] = 1, dry_run: bool | Literal[0, 1] = 0 ) -> _StrPathT | str: ... @overload def move_file( - src: BytesPath, dst: _BytesPathT, verbose: bool | Literal[0, 1] = 0, dry_run: bool | Literal[0, 1] = 0 + src: BytesPath, dst: _BytesPathT, verbose: bool | Literal[0, 1] = 1, dry_run: bool | Literal[0, 1] = 0 ) -> _BytesPathT | bytes: ... def write_file(filename: StrOrBytesPath, contents: Iterable[str]) -> None: ... diff --git a/stdlib/gettext.pyi b/stdlib/gettext.pyi index 937aece03437..ba616c899dc1 100644 --- a/stdlib/gettext.pyi +++ b/stdlib/gettext.pyi @@ -120,7 +120,7 @@ else: languages: Iterable[str] | None = None, class_: None = None, fallback: Literal[False] = False, - codeset: str | None = None, + codeset: str | None = ["unspecified"], ) -> GNUTranslations: ... @overload def translation( @@ -130,7 +130,7 @@ else: *, class_: Callable[[io.BufferedReader], _NullTranslationsT], fallback: Literal[False] = False, - codeset: str | None = None, + codeset: str | None = ["unspecified"], ) -> _NullTranslationsT: ... @overload def translation( @@ -139,7 +139,7 @@ else: languages: Iterable[str] | None, class_: Callable[[io.BufferedReader], _NullTranslationsT], fallback: Literal[False] = False, - codeset: str | None = None, + codeset: str | None = ["unspecified"], ) -> _NullTranslationsT: ... @overload def translation( @@ -148,11 +148,11 @@ else: languages: Iterable[str] | None = None, class_: Callable[[io.BufferedReader], NullTranslations] | None = None, fallback: bool = False, - codeset: str | None = None, + codeset: str | None = ["unspecified"], ) -> NullTranslations: ... @overload def install( - domain: str, localedir: StrPath | None = None, codeset: None = None, names: Container[str] | None = None + domain: str, localedir: StrPath | None = None, codeset: None = ["unspecified"], names: Container[str] | None = None ) -> None: ... @overload @deprecated("The `codeset` parameter is deprecated since Python 3.8; removed in Python 3.11.") diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index 060f8ad2dbd6..3467f86cc5ee 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -3475,7 +3475,7 @@ class Text(Widget, XView, YView): def image_configure( self, index: _TextIndex, - cnf: dict[str, Any] | None = {}, + cnf: dict[str, Any] | None = None, *, align: Literal["baseline", "bottom", "center", "top"] = ..., image: _ImageSpec = ..., From b40f5bbaa7f2be0d693d2587942a39eba9e0aca8 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 21 Aug 2025 21:17:48 -0700 Subject: [PATCH 2/4] fix --- stdlib/builtins.pyi | 2 +- stdlib/gettext.pyi | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index b4dd9a338dbb..c7ab95482f6b 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -1519,7 +1519,7 @@ help: _sitebuiltins._Helper def hex(number: int | SupportsIndex, /) -> str: ... def id(obj: object, /) -> int: ... -def input(prompt: object = None, /) -> str: ... +def input(prompt: object = "", /) -> str: ... @type_check_only class _GetItemIterable(Protocol[_T_co]): def __getitem__(self, i: int, /) -> _T_co: ... diff --git a/stdlib/gettext.pyi b/stdlib/gettext.pyi index ba616c899dc1..2997ffc6c930 100644 --- a/stdlib/gettext.pyi +++ b/stdlib/gettext.pyi @@ -120,7 +120,7 @@ else: languages: Iterable[str] | None = None, class_: None = None, fallback: Literal[False] = False, - codeset: str | None = ["unspecified"], + codeset: str = ..., ) -> GNUTranslations: ... @overload def translation( @@ -130,7 +130,7 @@ else: *, class_: Callable[[io.BufferedReader], _NullTranslationsT], fallback: Literal[False] = False, - codeset: str | None = ["unspecified"], + codeset: str = ..., ) -> _NullTranslationsT: ... @overload def translation( @@ -139,7 +139,7 @@ else: languages: Iterable[str] | None, class_: Callable[[io.BufferedReader], _NullTranslationsT], fallback: Literal[False] = False, - codeset: str | None = ["unspecified"], + codeset: str = ..., ) -> _NullTranslationsT: ... @overload def translation( @@ -148,12 +148,10 @@ else: languages: Iterable[str] | None = None, class_: Callable[[io.BufferedReader], NullTranslations] | None = None, fallback: bool = False, - codeset: str | None = ["unspecified"], + codeset: str = ..., ) -> NullTranslations: ... @overload - def install( - domain: str, localedir: StrPath | None = None, codeset: None = ["unspecified"], names: Container[str] | None = None - ) -> None: ... + def install(domain: str, localedir: StrPath | None = None, names: Container[str] | None = None) -> None: ... @overload @deprecated("The `codeset` parameter is deprecated since Python 3.8; removed in Python 3.11.") def install(domain: str, localedir: StrPath | None, codeset: str, /, names: Container[str] | None = None) -> None: ... From 1aa61e613d26e9c89547c95eb99d51a96ed3cf1e Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 21 Aug 2025 21:21:00 -0700 Subject: [PATCH 3/4] Try running stubdefaulter in CI --- .github/workflows/stubtest_stdlib.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/stubtest_stdlib.yml b/.github/workflows/stubtest_stdlib.yml index 2a574584ff08..62385f54168c 100644 --- a/.github/workflows/stubtest_stdlib.yml +++ b/.github/workflows/stubtest_stdlib.yml @@ -46,5 +46,9 @@ jobs: check-latest: true - name: Install dependencies run: pip install -r requirements-tests.txt + - name: Install stubdefaulter + run: pip install git+https://github.com/JelleZijlstra/stubdefaulter.git@d861cce40b1734c262d05dee2c1bf32358878103 + - name: Run stubdefaulter + run: stubdefaulter --stdlib stdlib - name: Run stubtest run: python tests/stubtest_stdlib.py From 42a5e2580a19a6a291c1e99e6e242588cfa7f953 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 21 Aug 2025 21:37:18 -0700 Subject: [PATCH 4/4] ? --- requirements-tests.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements-tests.txt b/requirements-tests.txt index 8fe57cf3624a..1b95fb467b8f 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -17,7 +17,6 @@ pre-commit # Required by create_baseline_stubs.py. Must match .pre-commit-config.yaml. ruff==0.12.2 # TODO (2025-05-07): Dependency libcst doesn't support Python 3.14 yet. -stubdefaulter==0.1.0; python_version < "3.14" termcolor>=2.3 tomli==2.2.1; python_version < "3.11" tomlkit==0.13.3