From b497ffbc7f3eee00376e7a09ab8352b9d1e99a11 Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Wed, 11 Oct 2023 00:58:35 +0200 Subject: [PATCH 1/2] Bump mypy to 1.6.0 --- requirements-tests.txt | 2 +- tests/stubtest_allowlists/darwin.txt | 1 + tests/stubtest_allowlists/linux.txt | 1 + tests/stubtest_allowlists/py310.txt | 15 ++++++ tests/stubtest_allowlists/py311.txt | 16 ++++++ tests/stubtest_allowlists/py312.txt | 7 +++ tests/stubtest_allowlists/py38.txt | 25 +++++++++- tests/stubtest_allowlists/py39.txt | 14 ++++++ tests/stubtest_allowlists/py3_common.txt | 63 +++++++++++++++++++++++- tests/stubtest_allowlists/win32.txt | 3 ++ 10 files changed, 144 insertions(+), 3 deletions(-) diff --git a/requirements-tests.txt b/requirements-tests.txt index 937d45d8af14..86271d02b284 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -7,7 +7,7 @@ flake8-bugbear==23.7.10 # must match .pre-commit-config.yaml flake8-noqa==1.3.2 # must match .pre-commit-config.yaml flake8-pyi==23.6.0 # must match .pre-commit-config.yaml isort==5.12.0 # must match .pre-commit-config.yaml -mypy==1.5.1 +mypy==1.6.0 pre-commit-hooks==4.4.0 # must match .pre-commit-config.yaml pytype==2023.8.31; platform_system != "Windows" and python_version < "3.11" ruff==0.0.292 # must match .pre-commit-config.yaml diff --git a/tests/stubtest_allowlists/darwin.txt b/tests/stubtest_allowlists/darwin.txt index 8e6610488dec..1d5283ca5df1 100644 --- a/tests/stubtest_allowlists/darwin.txt +++ b/tests/stubtest_allowlists/darwin.txt @@ -1,4 +1,5 @@ _posixsubprocess.cloexec_pipe +curses.has_key (os|posix).sched_param # system dependent. Unclear if macos has it. select.KQ_FILTER_NETDEV # system dependent select.kqueue.__init__ # default C signature is wrong diff --git a/tests/stubtest_allowlists/linux.txt b/tests/stubtest_allowlists/linux.txt index f2386ae01e98..cb7997a11af7 100644 --- a/tests/stubtest_allowlists/linux.txt +++ b/tests/stubtest_allowlists/linux.txt @@ -1,5 +1,6 @@ _socket.* _posixsubprocess.cloexec_pipe +curses.has_key os.plock selectors.KqueueSelector socket.[A-Z0-9_]+ diff --git a/tests/stubtest_allowlists/py310.txt b/tests/stubtest_allowlists/py310.txt index 816eb8436b45..535092fe6f31 100644 --- a/tests/stubtest_allowlists/py310.txt +++ b/tests/stubtest_allowlists/py310.txt @@ -24,6 +24,21 @@ types.GenericAlias.__call__ # Would be complicated to fix properly, Any could s typing._SpecialForm.__mro_entries__ weakref.ProxyType.__reversed__ # Doesn't really exist +# Modules that exist at runtime, but are missing from typeshed +importlib.readers + +# Modules that exist at runtime, but shouldn't be added to typeshed +ctypes.test +ctypes\.test\..+ +lib2to3.tests +lib2to3\.tests\..+ +sqlite3.test +sqlite3\.test\..+ +tkinter.test +tkinter\.test\..+ +unittest.test +unittest\.test\..+ + # Exist at runtime for internal reasons, no need to put them in the stub typing_extensions\.TypeAliasType\.__call__ typing_extensions\.TypeAliasType\.__init_subclass__ diff --git a/tests/stubtest_allowlists/py311.txt b/tests/stubtest_allowlists/py311.txt index 430be8820a84..7f5bb21a3a58 100644 --- a/tests/stubtest_allowlists/py311.txt +++ b/tests/stubtest_allowlists/py311.txt @@ -17,6 +17,22 @@ tkinter._VersionInfoType.__doc__ typing.NewType.__call__ typing.NewType.__mro_entries__ +# Modules that exist at runtime, but are missing from typeshed +importlib.readers +importlib.resources.readers +importlib.resources.simple +importlib.simple + +# Modules that exist at runtime, but shouldn't be added to typeshed +ctypes.test +ctypes\.test\..+ +lib2to3.tests +lib2to3\.tests\..+ +tkinter.test +tkinter\.test\..+ +unittest.test +unittest\.test\..+ + # ========== # Related to positional-only arguments # ========== diff --git a/tests/stubtest_allowlists/py312.txt b/tests/stubtest_allowlists/py312.txt index 80e6e1721486..58940a9cb57c 100644 --- a/tests/stubtest_allowlists/py312.txt +++ b/tests/stubtest_allowlists/py312.txt @@ -1,3 +1,10 @@ +# Modules that exist at runtime, but are missing from typeshed +zipfile._path.glob +importlib.readers +importlib.resources.readers +importlib.resources.simple +importlib.simple + # Errors that also existed on Python 3.11 _collections_abc.AsyncIterable.__class_getitem__ _collections_abc.Awaitable.__class_getitem__ diff --git a/tests/stubtest_allowlists/py38.txt b/tests/stubtest_allowlists/py38.txt index 01fc5d3c2d8f..38f474467d5e 100644 --- a/tests/stubtest_allowlists/py38.txt +++ b/tests/stubtest_allowlists/py38.txt @@ -1,4 +1,13 @@ -_dummy_threading +_dummy_threading.Condition.acquire +_dummy_threading.Condition.release +_dummy_threading.Event.isSet +_dummy_threading.ExceptHookArgs +_dummy_threading.Lock +_dummy_threading.RLock +_dummy_threading.Thread.native_id +_dummy_threading._DummyThread.__init__ +_dummy_threading._RLock.__enter__ +_dummy_threading.local.__new__ asyncio.locks._ContextManagerMixin.__enter__ # Always raises; deliberately omitted from the stub asyncio.locks._ContextManagerMixin.__exit__ # Always raises; deliberately omitted from the stub asyncio.transports.WriteTransport.get_write_buffer_limits # Documented. Exists in subclasses, but not in WriteTransport itself @@ -41,6 +50,7 @@ typing.NamedTuple._replace typing._SpecialForm.__new__ xml.etree.ElementTree.TreeBuilder.start # Discrepancy between Python and C modules, fixed in bpo-39495 xml.etree.cElementTree.TreeBuilder.start # bpo-39495 +xxsubtype # module missing from the stubs # Exist at runtime for internal reasons, no need to put them in the stub typing_extensions\.TypeAliasType\.__call__ @@ -158,3 +168,16 @@ pkgutil.ImpImporter\..* pkgutil.ImpLoader\..* types.CodeType.replace # stubtest thinks default values are None but None doesn't work at runtime + +# Modules that exist at runtime, but shouldn't be added to typeshed +ctypes.test +ctypes\.test\..+ +lib2to3.tests +lib2to3\.tests\..+ +sqlite3.test +sqlite3\.test\..+ +test +tkinter.test +tkinter\.test\..+ +unittest.test +unittest\.test\..+ diff --git a/tests/stubtest_allowlists/py39.txt b/tests/stubtest_allowlists/py39.txt index ce49b3ba6de7..88026b0c35d5 100644 --- a/tests/stubtest_allowlists/py39.txt +++ b/tests/stubtest_allowlists/py39.txt @@ -37,6 +37,7 @@ tkinter.Tk.split types.GenericAlias.__getattr__ types.GenericAlias.__call__ # Would be complicated to fix properly, Any could silence problems. #6392 weakref.ProxyType.__reversed__ # Doesn't really exist +xxsubtype # module missing from the stubs # Exist at runtime for internal reasons, no need to put them in the stub typing_extensions\.TypeAliasType\.__call__ @@ -55,6 +56,19 @@ collections.Generator.gi_yieldfrom collections.Mapping.get # Adding None to the Union messed up mypy collections.Sequence.index # Supporting None in end is not mandatory +# Modules that exist at runtime, but shouldn't be added to typeshed +ctypes.test +ctypes\.test\..+ +lib2to3.tests +lib2to3\.tests\..+ +sqlite3.test +sqlite3\.test\..+ +test +tkinter.test +tkinter\.test\..+ +unittest.test +unittest\.test\..+ + # Exists at runtime, but missing from stubs _collections_abc.AsyncIterable.__class_getitem__ _collections_abc.Awaitable.__class_getitem__ diff --git a/tests/stubtest_allowlists/py3_common.txt b/tests/stubtest_allowlists/py3_common.txt index a7db8a2a877e..a1d9b2b85b0d 100644 --- a/tests/stubtest_allowlists/py3_common.txt +++ b/tests/stubtest_allowlists/py3_common.txt @@ -134,8 +134,69 @@ xml.etree.ElementTree.XMLParser.__init__ # Defined in C so has general signatur xml.etree.cElementTree.XMLParser.__init__ # Defined in C so has general signature xml.parsers.expat.expat_CAPI +# Modules that exist at runtime, but shouldn't be added to typeshed +idlelib + +# ========== +# Modules that exist at runtime, but are missing from stubs +# ========== +ctypes.macholib +ctypes.macholib.dyld +ctypes.macholib.dylib +ctypes.macholib.framework +encodings.aliases +encodings.ascii +encodings.base64_codec +encodings.big5 +encodings.big5hkscs +encodings.bz2_codec +encodings.charmap +encodings\.cp\d+ +encodings\.euc_.+ +encodings.gb18030 +encodings.gb2312 +encodings.gbk +encodings.hex_codec +encodings.hp_roman8 +encodings.hz +encodings.idna +encodings\.iso2022_.* +encodings\.iso8859_\d+ +encodings.johab +encodings\.koi8_\w +encodings.kz1048 +encodings.latin_1 +encodings\.mac_.+ +encodings.palmos +encodings.ptcp154 +encodings.punycode +encodings.quopri_codec +encodings.raw_unicode_escape +encodings.rot_13 +encodings\.shift_jis.* +encodings.tis_620 +encodings.undefined +encodings.unicode_escape +encodings.utf_16 +encodings.utf_16_be +encodings.utf_16_le +encodings.utf_32 +encodings.utf_32_be +encodings.utf_32_le +encodings.utf_7 +encodings.uu_codec +encodings.zlib_codec +json.scanner +lib2to3.btm_utils +lib2to3.fixer_util +lib2to3.patcomp +sqlite3.dump +turtledemo +turtledemo\..+ +xml.sax.expatreader + # ========== -# Exists at runtime, but missing from stubs +# Module members that exist at runtime, but are missing from stubs # ========== _json.encode_basestring _socket.CAPI diff --git a/tests/stubtest_allowlists/win32.txt b/tests/stubtest_allowlists/win32.txt index 8577e1613716..1f3bc656ab95 100644 --- a/tests/stubtest_allowlists/win32.txt +++ b/tests/stubtest_allowlists/win32.txt @@ -4,6 +4,9 @@ ctypes.GetLastError # Is actually a pointer multiprocessing.reduction.AbstractReducer.DupHandle # Exists at runtime, but missing from stubs +encodings.mbcs +encodings.oem +nt _winapi.CreateFileMapping _winapi.MapViewOfFile _winapi.OpenFileMapping From 1614f2ed49102ebc5c193846a1e45c7ab95d825e Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Wed, 11 Oct 2023 01:12:28 +0200 Subject: [PATCH 2/2] add an ignore for invoke --- stubs/invoke/invoke/tasks.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/invoke/invoke/tasks.pyi b/stubs/invoke/invoke/tasks.pyi index 7a1188a4ea53..72a212644f31 100644 --- a/stubs/invoke/invoke/tasks.pyi +++ b/stubs/invoke/invoke/tasks.pyi @@ -57,7 +57,7 @@ class Task(Generic[_P, _R_co]): def get_arguments(self, ignore_unknown_help: bool | None = None) -> list[Argument]: ... @overload -def task( +def task( # type: ignore[misc] *args: Task[..., Any] | Call, name: str | None = ..., aliases: tuple[str, ...] = ...,