From 45dfa049a9898ccfda78e927f207c9ad79042e4a Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Tue, 22 Feb 2022 15:12:41 +0000 Subject: [PATCH 1/9] Increase pyright strictness when checking `__all__` --- pyrightconfig.json | 6 ++---- pyrightconfig.stricter.json | 8 +++----- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/pyrightconfig.json b/pyrightconfig.json index 19e2954f6998..c43c6a8b8032 100644 --- a/pyrightconfig.json +++ b/pyrightconfig.json @@ -43,12 +43,10 @@ "reportInvalidTypeVarUse": "error", "reportPropertyTypeMismatch": "error", "reportSelfClsParameterName": "error", + "reportUnsupportedDunderAll": "none", // Overlapping overloads cannot be enabled at this time because // of the "fractions.Fraction.__pow__" method and "tasks.gather" function. // Mypy's overlapping overload logic misses these issues (see mypy // issue #10143 and #10157). - "reportOverlappingOverload": "none", - // Several stubs refer to symbols in __all__ that are conditionally - // declared based on platform or version checks. - "reportUnsupportedDunderAll": "none", + "reportOverlappingOverload": "none", } diff --git a/pyrightconfig.stricter.json b/pyrightconfig.stricter.json index caae178514ab..1cc13afc78b7 100644 --- a/pyrightconfig.stricter.json +++ b/pyrightconfig.stricter.json @@ -110,12 +110,10 @@ "reportInvalidTypeVarUse": "error", "reportPropertyTypeMismatch": "error", "reportSelfClsParameterName": "error", + "reportUnsupportedDunderAll": "error", // Overlapping overloads cannot be enabled at this time because - // of the "factions.Fraction.__pow__" method and "tasks.gather" function. + // of the "fractions.Fraction.__pow__" method and "tasks.gather" function. // Mypy's overlapping overload logic misses these issues (see mypy // issue #10143 and #10157). - "reportOverlappingOverload": "none", - // Several stubs refer to symbols in __all__ that are conditionally - // declared based on platform or version checks. - "reportUnsupportedDunderAll": "none", + "reportOverlappingOverload": "none", } From 363893b76ab400603d5d55825db93b7c917c31bb Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Tue, 22 Feb 2022 15:13:29 +0000 Subject: [PATCH 2/9] Update pyrightconfig.json --- pyrightconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyrightconfig.json b/pyrightconfig.json index c43c6a8b8032..371d3e2ebe30 100644 --- a/pyrightconfig.json +++ b/pyrightconfig.json @@ -43,7 +43,7 @@ "reportInvalidTypeVarUse": "error", "reportPropertyTypeMismatch": "error", "reportSelfClsParameterName": "error", - "reportUnsupportedDunderAll": "none", + "reportUnsupportedDunderAll": "error", // Overlapping overloads cannot be enabled at this time because // of the "fractions.Fraction.__pow__" method and "tasks.gather" function. // Mypy's overlapping overload logic misses these issues (see mypy From a6eae3236a622e51ad77d11f94ea073631c273c9 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Tue, 22 Feb 2022 15:42:16 +0000 Subject: [PATCH 3/9] Fix typo in `locale.__all__` --- stdlib/locale.pyi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stdlib/locale.pyi b/stdlib/locale.pyi index 60945b886700..899bf0000a2c 100644 --- a/stdlib/locale.pyi +++ b/stdlib/locale.pyi @@ -20,7 +20,8 @@ __all__ = [ "normalize", "LC_CTYPE", "LC_COLLATE", - "LC_MESSAGES" "LC_TIME", + "LC_MESSAGES", + "LC_TIME", "LC_MONETARY", "LC_NUMERIC", "LC_ALL", From c8f7d5b728febd18fd8ef62dec6c3c54fa276001 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Wed, 23 Feb 2022 22:25:02 +0000 Subject: [PATCH 4/9] Delete `Popen` from `asyncio.windows_utils.__all__` --- stdlib/asyncio/windows_utils.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/asyncio/windows_utils.pyi b/stdlib/asyncio/windows_utils.pyi index bdc0212ca219..6564101c7ad5 100644 --- a/stdlib/asyncio/windows_utils.pyi +++ b/stdlib/asyncio/windows_utils.pyi @@ -7,9 +7,9 @@ from typing_extensions import Literal if sys.platform == "win32": if sys.version_info >= (3, 7): - __all__ = ("pipe", "Popen", "PIPE", "PipeHandle") + __all__ = ("pipe", "PIPE", "PipeHandle") else: - __all__ = ["socketpair", "pipe", "Popen", "PIPE", "PipeHandle"] + __all__ = ["socketpair", "pipe", "PIPE", "PipeHandle"] class _WarnFunction(Protocol): def __call__( From c2387d017ed4cdb7d47809eedde48e90180d3f97 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Wed, 23 Feb 2022 22:31:02 +0000 Subject: [PATCH 5/9] Fix typos in `re` --- stdlib/re.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/re.pyi b/stdlib/re.pyi index fe440a13c53a..b9c41e1caa16 100644 --- a/stdlib/re.pyi +++ b/stdlib/re.pyi @@ -126,7 +126,7 @@ class RegexFlag(enum.IntFlag): T = sre_compile.SRE_FLAG_TEMPLATE TEMPLATE = T if sys.version_info >= (3, 11): - NO_FLAG: int + NOFLAG: int A = RegexFlag.A ASCII = RegexFlag.ASCII @@ -146,7 +146,7 @@ UNICODE = RegexFlag.UNICODE T = RegexFlag.T TEMPLATE = RegexFlag.TEMPLATE if sys.version_info >= (3, 11): - NO_FLAG = RegexFlag.NO_FLAG + NOFLAG = RegexFlag.NOFLAG _FlagsType = Union[int, RegexFlag] if sys.version_info < (3, 7): From 2d3a5cd830eb8da47097431770d2379301044cd4 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Wed, 23 Feb 2022 22:38:25 +0000 Subject: [PATCH 6/9] Allow --- tests/stubtest_allowlists/win32-py310.txt | 3 +++ tests/stubtest_allowlists/win32-py37.txt | 3 +++ tests/stubtest_allowlists/win32-py38.txt | 3 +++ tests/stubtest_allowlists/win32-py39.txt | 3 +++ 4 files changed, 12 insertions(+) diff --git a/tests/stubtest_allowlists/win32-py310.txt b/tests/stubtest_allowlists/win32-py310.txt index 2fcacc00a5b2..5700ba0a7c5c 100644 --- a/tests/stubtest_allowlists/win32-py310.txt +++ b/tests/stubtest_allowlists/win32-py310.txt @@ -6,6 +6,9 @@ sqlite3.Connection.load_extension sqlite3.dbapi2.Connection.enable_load_extension sqlite3.dbapi2.Connection.load_extension +# Module is currently missing the Popen class +asyncio.windows_utils.__all__ + # pathlib methods that exist on Windows, but always raise NotImplementedError, # so are omitted from the stub pathlib.WindowsPath.is_mount diff --git a/tests/stubtest_allowlists/win32-py37.txt b/tests/stubtest_allowlists/win32-py37.txt index 0ab3ff7e0642..4a5539d1fedd 100644 --- a/tests/stubtest_allowlists/win32-py37.txt +++ b/tests/stubtest_allowlists/win32-py37.txt @@ -15,6 +15,9 @@ pathlib.WindowsPath.owner pathlib.Path.is_mount pathlib.WindowsPath.is_mount +# Module is currently missing the Popen class +asyncio.windows_utils.__all__ + os.startfile # Exists at runtime, but missing from stubs diff --git a/tests/stubtest_allowlists/win32-py38.txt b/tests/stubtest_allowlists/win32-py38.txt index bae39db2937e..07856f04a7b4 100644 --- a/tests/stubtest_allowlists/win32-py38.txt +++ b/tests/stubtest_allowlists/win32-py38.txt @@ -5,6 +5,9 @@ pathlib.WindowsPath.owner pathlib.Path.is_mount pathlib.WindowsPath.is_mount +# Module is currently missing the Popen class +asyncio.windows_utils.__all__ + # Exists at runtime, but missing from stubs _winapi.CreateFileMapping _winapi.MapViewOfFile diff --git a/tests/stubtest_allowlists/win32-py39.txt b/tests/stubtest_allowlists/win32-py39.txt index f8e07f9fd1ac..e8a3fffbd859 100644 --- a/tests/stubtest_allowlists/win32-py39.txt +++ b/tests/stubtest_allowlists/win32-py39.txt @@ -3,6 +3,9 @@ pathlib.Path.is_mount pathlib.WindowsPath.is_mount +# Module is currently missing the Popen class +asyncio.windows_utils.__all__ + # Exists at runtime, but missing from stubs _winapi.CreateFileMapping _winapi.MapViewOfFile From 9c18f92857b7831c8a5ce697fbea149baf20c51a Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Thu, 24 Feb 2022 02:40:53 +0000 Subject: [PATCH 7/9] Update types.pyi --- stdlib/types.pyi | 2 -- 1 file changed, 2 deletions(-) diff --git a/stdlib/types.pyi b/stdlib/types.pyi index 6a899fb576d8..90729323dd7d 100644 --- a/stdlib/types.pyi +++ b/stdlib/types.pyi @@ -155,14 +155,12 @@ else: "AsyncGeneratorType", "MethodType", "BuiltinFunctionType", - "ClassMethodDescriptorType", "ModuleType", "TracebackType", "FrameType", "GetSetDescriptorType", "MemberDescriptorType", "new_class", - "resolve_bases", "prepare_class", "DynamicClassAttribute", "coroutine", From b98775d99ca017eba1176ec0302d52f4033c9b43 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 27 Feb 2022 17:46:01 +0000 Subject: [PATCH 8/9] Revert changes to allowlists and `windows_utils` --- stdlib/asyncio/windows_utils.pyi | 2 +- tests/stubtest_allowlists/win32-py310.txt | 3 --- tests/stubtest_allowlists/win32-py37.txt | 3 --- tests/stubtest_allowlists/win32-py38.txt | 3 --- tests/stubtest_allowlists/win32-py39.txt | 3 --- 5 files changed, 1 insertion(+), 13 deletions(-) diff --git a/stdlib/asyncio/windows_utils.pyi b/stdlib/asyncio/windows_utils.pyi index fec920a634c0..78eff6956519 100644 --- a/stdlib/asyncio/windows_utils.pyi +++ b/stdlib/asyncio/windows_utils.pyi @@ -7,7 +7,7 @@ from typing_extensions import Literal if sys.platform == "win32": if sys.version_info >= (3, 7): - __all__ = ("pipe", "PIPE", "PipeHandle") + __all__ = ("pipe", "Popen", "PIPE", "PipeHandle") else: __all__ = ["socketpair", "pipe", "Popen", "PIPE", "PipeHandle"] import socket diff --git a/tests/stubtest_allowlists/win32-py310.txt b/tests/stubtest_allowlists/win32-py310.txt index 5700ba0a7c5c..2fcacc00a5b2 100644 --- a/tests/stubtest_allowlists/win32-py310.txt +++ b/tests/stubtest_allowlists/win32-py310.txt @@ -6,9 +6,6 @@ sqlite3.Connection.load_extension sqlite3.dbapi2.Connection.enable_load_extension sqlite3.dbapi2.Connection.load_extension -# Module is currently missing the Popen class -asyncio.windows_utils.__all__ - # pathlib methods that exist on Windows, but always raise NotImplementedError, # so are omitted from the stub pathlib.WindowsPath.is_mount diff --git a/tests/stubtest_allowlists/win32-py37.txt b/tests/stubtest_allowlists/win32-py37.txt index 4a5539d1fedd..0ab3ff7e0642 100644 --- a/tests/stubtest_allowlists/win32-py37.txt +++ b/tests/stubtest_allowlists/win32-py37.txt @@ -15,9 +15,6 @@ pathlib.WindowsPath.owner pathlib.Path.is_mount pathlib.WindowsPath.is_mount -# Module is currently missing the Popen class -asyncio.windows_utils.__all__ - os.startfile # Exists at runtime, but missing from stubs diff --git a/tests/stubtest_allowlists/win32-py38.txt b/tests/stubtest_allowlists/win32-py38.txt index 07856f04a7b4..bae39db2937e 100644 --- a/tests/stubtest_allowlists/win32-py38.txt +++ b/tests/stubtest_allowlists/win32-py38.txt @@ -5,9 +5,6 @@ pathlib.WindowsPath.owner pathlib.Path.is_mount pathlib.WindowsPath.is_mount -# Module is currently missing the Popen class -asyncio.windows_utils.__all__ - # Exists at runtime, but missing from stubs _winapi.CreateFileMapping _winapi.MapViewOfFile diff --git a/tests/stubtest_allowlists/win32-py39.txt b/tests/stubtest_allowlists/win32-py39.txt index e8a3fffbd859..f8e07f9fd1ac 100644 --- a/tests/stubtest_allowlists/win32-py39.txt +++ b/tests/stubtest_allowlists/win32-py39.txt @@ -3,9 +3,6 @@ pathlib.Path.is_mount pathlib.WindowsPath.is_mount -# Module is currently missing the Popen class -asyncio.windows_utils.__all__ - # Exists at runtime, but missing from stubs _winapi.CreateFileMapping _winapi.MapViewOfFile From 9fd443baf8058180ae492daa8066f1609fee5895 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 27 Feb 2022 17:47:55 +0000 Subject: [PATCH 9/9] Trailing whitespace --- pyrightconfig.json | 2 +- pyrightconfig.stricter.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyrightconfig.json b/pyrightconfig.json index 371d3e2ebe30..9ba71a6fee8c 100644 --- a/pyrightconfig.json +++ b/pyrightconfig.json @@ -48,5 +48,5 @@ // of the "fractions.Fraction.__pow__" method and "tasks.gather" function. // Mypy's overlapping overload logic misses these issues (see mypy // issue #10143 and #10157). - "reportOverlappingOverload": "none", + "reportOverlappingOverload": "none", } diff --git a/pyrightconfig.stricter.json b/pyrightconfig.stricter.json index 8b880b86906d..b19bffc4cc47 100644 --- a/pyrightconfig.stricter.json +++ b/pyrightconfig.stricter.json @@ -116,5 +116,5 @@ // of the "fractions.Fraction.__pow__" method and "tasks.gather" function. // Mypy's overlapping overload logic misses these issues (see mypy // issue #10143 and #10157). - "reportOverlappingOverload": "none", + "reportOverlappingOverload": "none", }