Skip to content

Commit

Permalink
Merge branch 'main' into pytype-on-windows-and-Python-3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam authored Sep 12, 2024
2 parents eeba1ec + d326c9b commit 4304b41
Show file tree
Hide file tree
Showing 36 changed files with 373 additions and 100 deletions.
1 change: 1 addition & 0 deletions pyrightconfig.stricter.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
"stubs/PyMySQL",
"stubs/python-crontab",
"stubs/python-dateutil",
"stubs/python-http-client",
"stubs/python-jose",
"stubs/pywin32",
"stubs/pyxdg",
Expand Down
8 changes: 8 additions & 0 deletions stdlib/@tests/stubtest_allowlists/darwin-py311.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,11 @@ ossaudiodev
fcntl.F_OFD_GETLK
fcntl.F_OFD_SETLK
fcntl.F_OFD_SETLKW

# Incompatible changes introduced in Python 3.11.10
# (Remove once 3.11.10 becomes available for MacOS)
email._header_value_parser.NLSET
email._header_value_parser.SPECIALSNL
email.errors.HeaderWriteError
email.utils.getaddresses
email.utils.parseaddr
5 changes: 0 additions & 5 deletions stdlib/@tests/stubtest_allowlists/py312.txt
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,3 @@ ctypes._endian.SIZEOF_TIME_T

# Incompatible changes introduced in Python 3.12.5
concurrent.futures.__all__
email._header_value_parser.NLSET
email._header_value_parser.SPECIALSNL
email._policybase.Policy.verify_generated_headers
email.errors.HeaderWriteError
email.policy.Policy.verify_generated_headers
10 changes: 2 additions & 8 deletions stdlib/@tests/stubtest_allowlists/py313.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

# TODO: triage these new errors
_tkinter.create
doctest.TestResults.__doc__
doctest.TestResults.__new__
importlib.resources.Anchor
importlib.resources.Resource
importlib.resources.__all__
Expand Down Expand Up @@ -119,6 +117,8 @@ ast.ImportFrom.level # None on the class, but never None on instances
builtins.property.__set_name__ # Doesn't actually exist
collections\.UserList\.index # ignoring pos-or-keyword parameter
dataclasses.KW_ONLY # white lies around defaults
doctest.TestResults.__match_args__ # Stubtest doesn't pick up override
doctest.TestResults._fields # Stubtest doesn't pick up override
enum.auto.__init__ # The stub for enum.auto is nothing like the implementation
enum.auto.value # The stub for enum.auto is nothing like the implementation
functools._lru_cache_wrapper.cache_parameters # Cannot be detected statically
Expand Down Expand Up @@ -191,9 +191,3 @@ codecs.xmlcharrefreplace_errors

# To match `dict`, we lie about the runtime, but use overloads to match the correct behavior
types.MappingProxyType.get

# logging.warn() was restored after the 3.13 release candidate, which is what CI is using
logging.__all__
logging.Logger.warn
logging.LoggerAdapter.warn
logging.warn
8 changes: 8 additions & 0 deletions stdlib/@tests/stubtest_allowlists/py38.txt
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,11 @@ tkinter.EventType.__new__
ctypes._endian.DEFAULT_MODE
ctypes._endian.RTLD_GLOBAL
ctypes._endian.RTLD_LOCAL

# Incompatible changes introduced in Python 3.8.20
# (Remove once 3.8.20 becomes available for GitHub Actions)
email._header_value_parser.NLSET
email._header_value_parser.SPECIALSNL
email.errors.HeaderWriteError
email.utils.getaddresses
email.utils.parseaddr
8 changes: 8 additions & 0 deletions stdlib/@tests/stubtest_allowlists/win32-py310.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,11 @@ crypt
nis
ossaudiodev
spwd

# Incompatible changes introduced in Python 3.10.15
# (Remove once 3.10.15 becomes available for Windows)
email._header_value_parser.NLSET
email._header_value_parser.SPECIALSNL
email.errors.HeaderWriteError
email.utils.getaddresses
email.utils.parseaddr
8 changes: 8 additions & 0 deletions stdlib/@tests/stubtest_allowlists/win32-py311.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,11 @@ crypt
nis
ossaudiodev
spwd

# Incompatible changes introduced in Python 3.11.10
# (Remove once 3.11.10 becomes available for Windows)
email._header_value_parser.NLSET
email._header_value_parser.SPECIALSNL
email.errors.HeaderWriteError
email.utils.getaddresses
email.utils.parseaddr
8 changes: 8 additions & 0 deletions stdlib/@tests/stubtest_allowlists/win32-py39.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,11 @@ crypt
nis
ossaudiodev
spwd

# Incompatible changes introduced in Python 3.9.20
# (Remove once 3.9.20 becomes available for Windows)
email._header_value_parser.NLSET
email._header_value_parser.SPECIALSNL
email.errors.HeaderWriteError
email.utils.getaddresses
email.utils.parseaddr
25 changes: 24 additions & 1 deletion stdlib/distutils/dist.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ class Distribution:
def has_data_files(self) -> bool: ...
def is_pure(self) -> bool: ...

# Getter methods generated in __init__
# Default getter methods generated in __init__ from self.metadata._METHOD_BASENAMES
def get_name(self) -> str: ...
def get_version(self) -> str: ...
def get_fullname(self) -> str: ...
Expand All @@ -292,3 +292,26 @@ class Distribution:
def get_requires(self) -> list[str]: ...
def get_provides(self) -> list[str]: ...
def get_obsoletes(self) -> list[str]: ...

# Default attributes generated in __init__ from self.display_option_names
help_commands: bool | Literal[0]
name: str | Literal[0]
version: str | Literal[0]
fullname: str | Literal[0]
author: str | Literal[0]
author_email: str | Literal[0]
maintainer: str | Literal[0]
maintainer_email: str | Literal[0]
contact: str | Literal[0]
contact_email: str | Literal[0]
url: str | Literal[0]
license: str | Literal[0]
licence: str | Literal[0]
description: str | Literal[0]
long_description: str | Literal[0]
platforms: str | list[str] | Literal[0]
classifiers: str | list[str] | Literal[0]
keywords: str | list[str] | Literal[0]
provides: list[str] | Literal[0]
requires: list[str] | Literal[0]
obsoletes: list[str] | Literal[0]
26 changes: 21 additions & 5 deletions stdlib/doctest.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import sys
import types
import unittest
from _typeshed import ExcInfo
from collections.abc import Callable
from typing import Any, NamedTuple
from typing_extensions import TypeAlias
from typing import Any, ClassVar, NamedTuple
from typing_extensions import Self, TypeAlias

__all__ = [
"register_optionflag",
Expand Down Expand Up @@ -41,9 +42,22 @@ __all__ = [
"debug",
]

class TestResults(NamedTuple):
failed: int
attempted: int
# MyPy errors on conditionals within named tuples.

if sys.version_info >= (3, 13):
class TestResults(NamedTuple):
def __new__(cls, failed: int, attempted: int, *, skipped: int = 0) -> Self: ... # type: ignore[misc]
skipped: int
failed: int
attempted: int
_fields: ClassVar = ("failed", "attempted") # type: ignore[misc]
__match_args__ = ("failed", "attempted") # type: ignore[misc]
__doc__: None # type: ignore[misc]

else:
class TestResults(NamedTuple):
failed: int
attempted: int

OPTIONFLAGS_BY_NAME: dict[str, int]

Expand Down Expand Up @@ -134,6 +148,8 @@ class DocTestRunner:
original_optionflags: int
tries: int
failures: int
if sys.version_info >= (3, 13):
skips: int
test: DocTest
def __init__(self, checker: OutputChecker | None = None, verbose: bool | None = None, optionflags: int = 0) -> None: ...
def report_start(self, out: _Out, test: DocTest, example: Example) -> None: ...
Expand Down
4 changes: 4 additions & 0 deletions stdlib/email/_header_value_parser.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ TOKEN_ENDS: Final[set[str]]
ASPECIALS: Final[set[str]]
ATTRIBUTE_ENDS: Final[set[str]]
EXTENDED_ATTRIBUTE_ENDS: Final[set[str]]
# Added in Python 3.8.20, 3.9.20, 3.10.15, 3.11.10, 3.12.5
NLSET: Final[set[str]]
# Added in Python 3.8.20, 3.9.20, 3.10.15, 3.11.10, 3.12.5
SPECIALSNL: Final[set[str]]

def quote_string(value: Any) -> str: ...

Expand Down
39 changes: 27 additions & 12 deletions stdlib/email/_policybase.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,45 @@ from collections.abc import Callable
from email.errors import MessageDefect
from email.header import Header
from email.message import Message
from typing import Any
from typing_extensions import Self

class _PolicyBase:
def __add__(self, other: Any) -> Self: ...
def clone(self, **kw: Any) -> Self: ...

class Policy(_PolicyBase, metaclass=ABCMeta):
max_line_length: int | None
linesep: str
cte_type: str
raise_on_defect: bool
mangle_from_: bool
message_factory: Callable[[Policy], Message] | None
def __init__(
self,
*,
max_line_length: int | None = 78,
linesep: str = "\n",
cte_type: str = "8bit",
raise_on_defect: bool = False,
mangle_from_: bool = False,
mangle_from_: bool = ..., # default depends on sub-class
message_factory: Callable[[Policy], Message] | None = None,
# Added in Python 3.8.20, 3.9.20, 3.10.15, 3.11.10, 3.12.5
verify_generated_headers: bool = True,
) -> None: ...
def clone(
self,
*,
max_line_length: int | None = ...,
linesep: str = ...,
cte_type: str = ...,
raise_on_defect: bool = ...,
mangle_from_: bool = ...,
message_factory: Callable[[Policy], Message] | None = ...,
# Added in Python 3.8.20, 3.9.20, 3.10.15, 3.11.10, 3.12.5
verify_generated_headers: bool = ...,
) -> Self: ...
def __add__(self, other: Policy) -> Self: ...

class Policy(_PolicyBase, metaclass=ABCMeta):
max_line_length: int | None
linesep: str
cte_type: str
raise_on_defect: bool
mangle_from_: bool
message_factory: Callable[[Policy], Message] | None
# Added in Python 3.8.20, 3.9.20, 3.10.15, 3.11.10, 3.12.5
verify_generated_headers: bool

def handle_defect(self, obj: Message, defect: MessageDefect) -> None: ...
def register_defect(self, obj: Message, defect: MessageDefect) -> None: ...
def header_max_count(self, name: str) -> int | None: ...
Expand Down
3 changes: 3 additions & 0 deletions stdlib/email/errors.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ class BoundaryError(MessageParseError): ...
class MultipartConversionError(MessageError, TypeError): ...
class CharsetError(MessageError): ...

# Added in Python 3.8.20, 3.9.20, 3.10.15, 3.11.10, 3.12.5
class HeaderWriteError(MessageError): ...

class MessageDefect(ValueError):
def __init__(self, line: str | None = None) -> None: ...

Expand Down
16 changes: 4 additions & 12 deletions stdlib/email/utils.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,12 @@ _PDTZ: TypeAlias = tuple[int, int, int, int, int, int, int, int, int, int | None
def quote(str: str) -> str: ...
def unquote(str: str) -> str: ...

if sys.version_info >= (3, 13):
def parseaddr(addr: str | list[str], *, strict: bool = True) -> tuple[str, str]: ...

else:
def parseaddr(addr: str) -> tuple[str, str]: ...

# `strict` parameter added in Python 3.8.20, 3.9.20, 3.10.15, 3.11.10, 3.12.5
def parseaddr(addr: str | list[str], *, strict: bool = True) -> tuple[str, str]: ...
def formataddr(pair: tuple[str | None, str], charset: str | Charset = "utf-8") -> str: ...

if sys.version_info >= (3, 13):
def getaddresses(fieldvalues: Iterable[str], *, strict: bool = True) -> list[tuple[str, str]]: ...

else:
def getaddresses(fieldvalues: Iterable[str]) -> list[tuple[str, str]]: ...

# `strict` parameter added in Python 3.8.20, 3.9.20, 3.10.15, 3.11.10, 3.12.5
def getaddresses(fieldvalues: Iterable[str], *, strict: bool = True) -> list[tuple[str, str]]: ...
@overload
def parsedate(data: None) -> None: ...
@overload
Expand Down
6 changes: 3 additions & 3 deletions stdlib/tempfile.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,11 @@ class _TemporaryFileWrapper(IO[AnyStr]):
def truncate(self, size: int | None = ...) -> int: ...
def writable(self) -> bool: ...
@overload
def write(self: _TemporaryFileWrapper[str], s: str) -> int: ...
def write(self: _TemporaryFileWrapper[str], s: str, /) -> int: ...
@overload
def write(self: _TemporaryFileWrapper[bytes], s: ReadableBuffer) -> int: ...
def write(self: _TemporaryFileWrapper[bytes], s: ReadableBuffer, /) -> int: ...
@overload
def write(self, s: AnyStr) -> int: ...
def write(self, s: AnyStr, /) -> int: ...
@overload
def writelines(self: _TemporaryFileWrapper[str], lines: Iterable[str]) -> None: ...
@overload
Expand Down
9 changes: 7 additions & 2 deletions stubs/docutils/docutils/nodes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -416,10 +416,15 @@ class system_message(Special, BackLinkable, PreBibliographic, Element):
def __init__(self, message: str | None = None, *children: Node, **attributes) -> None: ...

class pending(Special, Invisible, Element):
transform: Transform
transform: type[Transform]
details: Mapping[str, Any]
def __init__(
self, transform: Transform, details: Mapping[str, Any] | None = None, rawsource: str = "", *children: Node, **attributes
self,
transform: type[Transform],
details: Mapping[str, Any] | None = None,
rawsource: str = "",
*children: Node,
**attributes,
) -> None: ...

class raw(Special, Inline, PreBibliographic, FixedTextElement): ...
Expand Down
4 changes: 2 additions & 2 deletions stubs/docutils/docutils/parsers/rst/directives/references.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from _typeshed import Incomplete
from docutils.parsers.rst import Directive

def __getattr__(name: str) -> Incomplete: ...
class TargetNotes(Directive): ...
2 changes: 1 addition & 1 deletion stubs/mysqlclient/MySQLdb/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ DATETIME: Incomplete
ROWID: Incomplete

def Binary(x): ...
def Connect(*args, **kwargs): ...
def Connect(*args, **kwargs) -> Connection: ...

connect = Connect
2 changes: 1 addition & 1 deletion stubs/networkx/networkx/classes/reportviews.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class NodeDataView(AbstractSet[_Node]):

class DiDegreeView(Generic[_Node]):
def __init__(self, G: Graph[_Node], nbunch: _NBunch[_Node] = None, weight: None | bool | str = None) -> None: ...
def __call__(self, nbunch: _NBunch[_Node] = None, weight: None | bool | str = None) -> DiDegreeView[_Node]: ...
def __call__(self, nbunch: _NBunch[_Node] = None, weight: None | bool | str = None) -> int | DiDegreeView[_Node]: ...
def __getitem__(self, n: _Node) -> float: ...
def __iter__(self) -> Iterator[tuple[_Node, float]]: ...
def __len__(self) -> int: ...
Expand Down
2 changes: 2 additions & 0 deletions stubs/objgraph/METADATA.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version = "3.6.*"
upstream_repository = "https://github.com/mgedmin/objgraph"
Loading

0 comments on commit 4304b41

Please sign in to comment.