Skip to content

Commit

Permalink
Update stubtest for submodule versions, typeddict fix (#7306)
Browse files Browse the repository at this point in the history
First step in #7305

Co-authored-by: hauntsaninja <>
  • Loading branch information
hauntsaninja authored Feb 19, 2022
1 parent 49aa342 commit 879b617
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 44 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/stubtest.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Run stubtest on all stubs
name: Daily test

on:
workflow_dispatch:
Expand Down Expand Up @@ -35,7 +35,11 @@ jobs:
- name: Update pip
run: python -m pip install -U pip
- name: Install dependencies
run: pip install $(grep tomli== requirements-tests.txt) $(grep mypy== requirements-tests.txt)
# Use pre-release stubtest. Keep the following in sync:
# - get_mypy_req in tests/stubtest_third_party.py
# - stubtest-stdlib in .github/workflows/stubtest.yml
# - stubtest-stdlib in .github/workflows/tests.yml
run: pip install $(grep tomli== requirements-tests.txt) git+git://github.com/python/mypy@b36d8cf5d4d0bb77c5a8cf783ba4def16cd9846a
- name: Run stubtest
run: python tests/stubtest_stdlib.py

Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Check stubs
name: Test

on:
workflow_dispatch:
Expand Down Expand Up @@ -110,7 +110,11 @@ jobs:
- name: Update pip
run: python -m pip install -U pip
- name: Install dependencies
run: pip install $(grep tomli== requirements-tests.txt) $(grep mypy== requirements-tests.txt)
# Use pre-release stubtest. Keep the following in sync:
# - get_mypy_req in tests/stubtest_third_party.py
# - stubtest-stdlib in .github/workflows/stubtest.yml
# - stubtest-stdlib in .github/workflows/tests.yml
run: pip install $(grep tomli== requirements-tests.txt) git+git://github.com/python/mypy@b36d8cf5d4d0bb77c5a8cf783ba4def16cd9846a
- name: Run stubtest
run: python tests/stubtest_stdlib.py

Expand Down
5 changes: 1 addition & 4 deletions tests/stubtest_allowlists/py310.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,10 @@ ast.Index.__new__
ast.NameConstant.__new__
ast.Num.__new__
ast.Str.__new__
asyncio.compat # module removed in 3.7
asyncio.Future.__init__ # Usually initialized from c object
asyncio.Future._callbacks # Usually initialized from c object
asyncio.futures.Future.__init__ # Usually initialized from c object
asyncio.futures.Future._callbacks # Usually initialized from c object
asyncio.taskgroups # Added in Python 3.11
builtins.dict.get
contextvars.Context.__init__ # Default C __init__ signature is wrong
contextlib.AbstractAsyncContextManager.__class_getitem__
Expand Down Expand Up @@ -69,6 +67,7 @@ multiprocessing.spawn._main
os.PathLike.__class_getitem__ # PathLike is a protocol; we don't expect all PathLike classes to implement class_getitem
pickle.Pickler.reducer_override # implemented in C pickler
# platform.uname_result's processor field is now dynamically made to exist
platform.uname_result.__match_args__
platform.uname_result.__new__
platform.uname_result._fields
platform.uname_result.processor
Expand Down Expand Up @@ -130,8 +129,6 @@ os.path.join
pstats.SortKey.__new__
tkinter.EventType.__new__

distutils.command.bdist_wininst # removed in 3.10

# stubtest complains that in 3.10 the default argument is inconsistent with the annotation,
# but in 3.10+ calling the function without the default argument is in fact deprecated,
# so it's better to ignore stubtest
Expand Down
13 changes: 0 additions & 13 deletions tests/stubtest_allowlists/py36.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,8 @@ _collections_abc.AsyncGenerator.ag_frame
_collections_abc.AsyncGenerator.ag_running
_dummy_threading
asyncio.Future.__init__ # Usually initialized from c object
asyncio.exceptions # Added in Python 3.8
asyncio.format_helpers # Added in Python 3.7
asyncio.futures.Future.__init__ # Usually initialized from c object
asyncio.futures._TracebackLogger.__init__
asyncio.runners # Added in Python 3.7
asyncio.staggered # Added in Python 3.8
asyncio.threads # Added in Python 3.9
asyncio.trsock # Added in Python 3.8
asyncio.mixins # Added in Python 3.10
asyncio.taskgroups # Added in Python 3.11
builtins.str.maketrans
cmath.log
collections.AsyncGenerator.ag_await
Expand All @@ -34,9 +26,6 @@ dummy_threading.local.__new__
enum.Enum._generate_next_value_
fractions.Fraction.__new__ # overload is too complicated for stubtest to resolve
hmac.HMAC.__init__
importlib.metadata # Added in 3.8
importlib.metadata._meta # Added in 3.10
importlib.resources # Added in 3.7
io.StringIO.readline
ipaddress._BaseNetwork.__init__
json.loads
Expand Down Expand Up @@ -72,8 +61,6 @@ typing.Sequence.index
typing.Text.maketrans
typing.runtime_checkable
typing\.\w+\.__new__
unittest._log # New in Python 3.9
unittest.async_case # Added in Python 3.8
uuid.UUID.int
uuid.libname
xml.etree.ElementTree.TreeBuilder.start # Discrepancy between Python and C modules, fixed in bpo-39495
Expand Down
11 changes: 0 additions & 11 deletions tests/stubtest_allowlists/py37.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,10 @@ _collections_abc.AsyncGenerator.ag_code
_collections_abc.AsyncGenerator.ag_frame
_collections_abc.AsyncGenerator.ag_running
_dummy_threading
asyncio.compat # Removed in 3.7
asyncio.Future.__init__ # Usually initialized from c object
asyncio.Future._callbacks # Usually initialized from c object
asyncio.exceptions # Added in Python 3.8
asyncio.futures.Future.__init__ # Usually initialized from c object
asyncio.futures.Future._callbacks # Usually initialized from c object
asyncio.staggered # Added in Python 3.8
asyncio.threads # Added in Python 3.9
asyncio.trsock # Added in Python 3.8
asyncio.mixins # Added in Python 3.10
asyncio.taskgroups # Added in Python 3.11
builtins.dict.get
builtins.str.maketrans
cmath.log
Expand All @@ -34,8 +27,6 @@ enum.Enum._generate_next_value_
fractions.Fraction.__new__ # overload is too complicated for stubtest to resolve
hmac.HMAC.__init__
http.server.SimpleHTTPRequestHandler.__init__ # *args is expanded
importlib.metadata # Added in 3.8
importlib.metadata._meta # Added in 3.10
ipaddress._BaseNetwork.__init__
json.loads
multiprocessing.shared_memory
Expand All @@ -58,8 +49,6 @@ typing._SpecialForm.__init__
typing._SpecialForm.__new__
typing.runtime_checkable
typing.Text.maketrans
unittest._log # New in Python 3.9
unittest.async_case # Added in Python 3.8
uuid.UUID.int
uuid.UUID.is_safe
uuid.getnode # undocumented, unused parameter getters that was later removed
Expand Down
6 changes: 0 additions & 6 deletions tests/stubtest_allowlists/py38.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,10 @@ ast.Ellipsis.__new__
ast.NameConstant.__new__
ast.Num.__new__
ast.Str.__new__
asyncio.compat # removed in 3.7
asyncio.Future.__init__ # Usually initialized from c object
asyncio.Future._callbacks # Usually initialized from c object
asyncio.futures.Future.__init__ # Usually initialized from c object
asyncio.futures.Future._callbacks # Usually initialized from c object
asyncio.threads # Added in Python 3.9
asyncio.mixins # Added in Python 3.10
asyncio.taskgroups # Added in Python 3.11
builtins.dict.get
collections.AsyncGenerator.ag_await
collections.AsyncGenerator.ag_code
Expand All @@ -42,7 +38,6 @@ gettext.install # codeset default value is ['unspecified'] so can't be specifie
gettext.translation # codeset default value is ['unspecified'] so can't be specified
hmac.new # Stub is a white lie; see comments in the stub
http.server.SimpleHTTPRequestHandler.__init__ # *args is expanded
importlib.metadata._meta # Added in 3.10
ipaddress.IPv4Interface.hostmask
ipaddress.IPv6Interface.hostmask
ipaddress._BaseNetwork.broadcast_address
Expand Down Expand Up @@ -74,7 +69,6 @@ typing.SupportsInt.__init__
typing.SupportsRound.__init__
typing._SpecialForm.__init__
typing._SpecialForm.__new__
unittest._log # New in Python 3.9
uuid.getnode # undocumented, unused parameter getters that was later removed
weakref.WeakValueDictionary.update
xml.etree.ElementTree.TreeBuilder.start # Discrepancy between Python and C modules, fixed in bpo-39495
Expand Down
4 changes: 0 additions & 4 deletions tests/stubtest_allowlists/py39.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,10 @@ ast.Index.__new__
ast.NameConstant.__new__
ast.Num.__new__
ast.Str.__new__
asyncio.compat # module removed in 3.7
asyncio.Future.__init__ # Usually initialized from c object
asyncio.Future._callbacks # Usually initialized from c object
asyncio.futures.Future.__init__ # Usually initialized from c object
asyncio.futures.Future._callbacks # Usually initialized from c object
asyncio.mixins # Added in Python 3.10
asyncio.taskgroups # Added in Python 3.11
builtins.dict.get
collections.AsyncGenerator.ag_await
collections.AsyncGenerator.ag_code
Expand All @@ -44,7 +41,6 @@ hashlib.shake_\d+
hmac.new # Stub is a white lie; see comments in the stub
http.server.SimpleHTTPRequestHandler.__init__ # *args is expanded
importlib.abc.Traversable.__init__ # Inherits __init__ from typing.Protocol
importlib.metadata._meta # Added in 3.10
ipaddress.IPv4Interface.hostmask
ipaddress.IPv6Interface.hostmask
ipaddress._BaseNetwork.broadcast_address
Expand Down
2 changes: 0 additions & 2 deletions tests/stubtest_allowlists/py3_common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,6 @@ multiprocessing.dummy.Lock # Similar to above
multiprocessing.dummy.RLock # Similar to above
tkinter.Misc.grid_propagate # The noarg placeholder is a set value list
tkinter.Misc.pack_propagate # The noarg placeholder is a set value list
tkinter.Misc.grid_columnconfigure # an empty dict literal is actually a valid default for a TypedDict(total=False) parameter
tkinter.Misc.grid_rowconfigure # an empty dict literal is actually a valid default for a TypedDict(total=False) parameter
tkinter.Tk.eval # from __getattr__
tkinter.Tk.report_callback_exception # A bit of a lie, since it's actually a method, but typing it as an attribute allows it to be assigned to
tkinter.Wm.wm_iconphoto # Default value of argument can't be used without runtime error
Expand Down
6 changes: 6 additions & 0 deletions tests/stubtest_third_party.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@

@functools.lru_cache()
def get_mypy_req():
# Use pre-release stubtest. Keep the following in sync:
# - get_mypy_req in tests/stubtest_third_party.py
# - stubtest-stdlib in .github/workflows/stubtest.yml
# - stubtest-stdlib in .github/workflows/tests.yml
return "git+git://github.com/python/mypy@b36d8cf5d4d0bb77c5a8cf783ba4def16cd9846a"

with open("requirements-tests.txt") as f:
return next(line.strip() for line in f if "mypy" in line)

Expand Down

0 comments on commit 879b617

Please sign in to comment.