dataclasses: fix and sort stubtest complaints (#7888)

This commit is contained in:
Jelle Zijlstra
2022-05-19 19:13:22 -07:00
committed by GitHub
parent 4220712aab
commit 0b7df3b2aa
6 changed files with 37 additions and 9 deletions

View File

@@ -240,7 +240,26 @@ class InitVar(Generic[_T]):
@overload
def __class_getitem__(cls, type: Any) -> InitVar[Any]: ...
if sys.version_info >= (3, 10):
if sys.version_info >= (3, 11):
def make_dataclass(
cls_name: str,
fields: Iterable[str | tuple[str, type] | tuple[str, type, Any]],
*,
bases: tuple[type, ...] = ...,
namespace: dict[str, Any] | None = ...,
init: bool = ...,
repr: bool = ...,
eq: bool = ...,
order: bool = ...,
unsafe_hash: bool = ...,
frozen: bool = ...,
match_args: bool = ...,
kw_only: bool = ...,
slots: bool = ...,
weakref_slot: bool = ...,
) -> type: ...
elif sys.version_info >= (3, 10):
def make_dataclass(
cls_name: str,
fields: Iterable[str | tuple[str, type] | tuple[str, type, Any]],

View File

@@ -14,8 +14,6 @@ builtins.float.__setformat__ # Internal method for CPython test suite
builtins.property.__set_name__ # Doesn't actually exist
contextlib.AbstractAsyncContextManager.__class_getitem__
contextlib.AbstractContextManager.__class_getitem__
dataclasses.field
dataclasses.KW_ONLY
enum.Enum._generate_next_value_
fractions.Fraction.__new__ # overload is too complicated for stubtest to resolve
gettext.install
@@ -194,3 +192,7 @@ ast.ImportFrom.level # None on the class, but never None on instances
# These enums derive from (str, Enum). See comment in py3_common.txt
pstats.SortKey.__new__
tkinter.EventType.__new__
# White lies around defaults
dataclasses.field
dataclasses.KW_ONLY

View File

@@ -41,9 +41,6 @@ concurrent.futures.process._process_worker
concurrent.futures.process._sendback_result
configparser.LegacyInterpolation.__init__
contextvars.Context.__init__
dataclasses.KW_ONLY
dataclasses.field
dataclasses.make_dataclass
distutils.dist.DistributionMetadata.set_classifiers
distutils.dist.DistributionMetadata.set_keywords
distutils.dist.DistributionMetadata.set_platforms
@@ -264,6 +261,10 @@ typing._TypedDict.setdefault
typing._TypedDict.update
typing._TypedDict.values
# White lies around defaults
dataclasses.KW_ONLY
dataclasses.field
# https://github.com/python/mypy/issues/12819 (... in runtime default)
wsgiref.types.InputStream.read
wsgiref.types.InputStream.readline

View File

@@ -27,7 +27,6 @@ collections.Callable
collections.Mapping.__reversed__ # Set to None at runtime for a better error message
collections.UserString.maketrans
contextvars.ContextVar.get
dataclasses.field
distutils.command.bdist_wininst # see #6523
dummy_threading.Condition.acquire
dummy_threading.Condition.release
@@ -171,3 +170,6 @@ queue.SimpleQueue.__init__
pyexpat.XMLParserType.ExternalEntityParserCreate # C signature is wrong - function gets only positional args
xml.parsers.expat.XMLParserType.ExternalEntityParserCreate # C signature is wrong - function gets only positional args
# White lies around defaults
dataclasses.field

View File

@@ -32,7 +32,6 @@ collections.ItemsView.__reversed__
collections.KeysView.__reversed__
collections.ValuesView.__reversed__
collections.Mapping.__reversed__ # Set to None at runtime for a better error message
dataclasses.field
distutils.command.bdist_wininst # see #6523
dummy_threading.Condition.acquire
dummy_threading.Condition.release
@@ -195,3 +194,6 @@ queue.SimpleQueue.__init__
uuid.getnode # undocumented, unused parameter getters that was later removed
types.CodeType.replace # stubtest thinks default values are None but None doesn't work at runtime
# White lies around defaults
dataclasses.field

View File

@@ -32,7 +32,6 @@ collections.KeysView.__reversed__
collections.ValuesView.__reversed__
contextlib.AbstractAsyncContextManager.__class_getitem__
contextlib.AbstractContextManager.__class_getitem__
dataclasses.field
distutils.command.bdist_wininst # see #6523
enum.Enum._generate_next_value_
fractions.Fraction.__new__ # overload is too complicated for stubtest to resolve
@@ -195,3 +194,6 @@ ast.ImportFrom.level # None on the class, but never None on instances
ftplib.FTP.trust_server_pasv_ipv4_address # Dangerous to use, intentionally undocumented, intentionally missing from typeshed. #6154
os.PathLike.__class_getitem__ # PathLike is a protocol; we don't expect all PathLike classes to implement class_getitem
# White lies around defaults
dataclasses.field