diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3c20c6357..c023d8b1c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,7 +26,7 @@ repos: additional_dependencies: - "flake8-bugbear==23.9.16" # must match requirements-tests.txt - "flake8-noqa==1.3.2" # must match requirements-tests.txt - - "flake8-pyi==23.10.0" # must match requirements-tests.txt + - "flake8-pyi==23.11.0" # must match requirements-tests.txt types: [file] types_or: [python, pyi] diff --git a/requirements-tests.txt b/requirements-tests.txt index 54897182a..d6e150d08 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -5,7 +5,7 @@ black==23.9.1 # must match .pre-commit-config.yaml flake8==6.1.0 # must match .pre-commit-config.yaml flake8-bugbear==23.9.16 # must match .pre-commit-config.yaml flake8-noqa==1.3.2 # must match .pre-commit-config.yaml -flake8-pyi==23.10.0 # must match .pre-commit-config.yaml +flake8-pyi==23.11.0 # must match .pre-commit-config.yaml mypy==1.6.1 pre-commit-hooks==4.5.0 # must match .pre-commit-config.yaml pytype==2023.10.17; platform_system != "Windows" and python_version < "3.12" diff --git a/stdlib/_ast.pyi b/stdlib/_ast.pyi index 402b770c0..0302133fc 100644 --- a/stdlib/_ast.pyi +++ b/stdlib/_ast.pyi @@ -553,7 +553,7 @@ if sys.version_info >= (3, 10): class MatchSingleton(pattern): __match_args__ = ("value",) - value: Literal[True, False, None] + value: Literal[True, False] | None class MatchSequence(pattern): __match_args__ = ("patterns",) diff --git a/stdlib/asyncio/base_events.pyi b/stdlib/asyncio/base_events.pyi index e2b55da8c..cdf295d51 100644 --- a/stdlib/asyncio/base_events.pyi +++ b/stdlib/asyncio/base_events.pyi @@ -423,7 +423,7 @@ class BaseEventLoop(AbstractEventLoop): bufsize: Literal[0] = 0, encoding: None = None, errors: None = None, - text: Literal[False, None] = None, + text: Literal[False] | None = None, **kwargs: Any, ) -> tuple[SubprocessTransport, _ProtocolT]: ... async def subprocess_exec( diff --git a/stdlib/asyncio/events.pyi b/stdlib/asyncio/events.pyi index cde63b279..4c6204387 100644 --- a/stdlib/asyncio/events.pyi +++ b/stdlib/asyncio/events.pyi @@ -522,7 +522,7 @@ class AbstractEventLoop: bufsize: Literal[0] = 0, encoding: None = None, errors: None = None, - text: Literal[False, None] = ..., + text: Literal[False] | None = ..., **kwargs: Any, ) -> tuple[SubprocessTransport, _ProtocolT]: ... @abstractmethod diff --git a/stdlib/asyncio/subprocess.pyi b/stdlib/asyncio/subprocess.pyi index b8877b360..9b7c82e68 100644 --- a/stdlib/asyncio/subprocess.pyi +++ b/stdlib/asyncio/subprocess.pyi @@ -54,7 +54,7 @@ if sys.version_info >= (3, 11): bufsize: Literal[0] = 0, encoding: None = None, errors: None = None, - text: Literal[False, None] = None, + text: Literal[False] | None = None, # These parameters are taken by subprocess.Popen, which this ultimately delegates to executable: StrOrBytesPath | None = None, preexec_fn: Callable[[], Any] | None = None, @@ -120,7 +120,7 @@ elif sys.version_info >= (3, 10): bufsize: Literal[0] = 0, encoding: None = None, errors: None = None, - text: Literal[False, None] = None, + text: Literal[False] | None = None, # These parameters are taken by subprocess.Popen, which this ultimately delegates to executable: StrOrBytesPath | None = None, preexec_fn: Callable[[], Any] | None = None, @@ -185,7 +185,7 @@ else: # >= 3.9 bufsize: Literal[0] = 0, encoding: None = None, errors: None = None, - text: Literal[False, None] = None, + text: Literal[False] | None = None, # These parameters are taken by subprocess.Popen, which this ultimately delegates to executable: StrOrBytesPath | None = None, preexec_fn: Callable[[], Any] | None = None, diff --git a/stdlib/subprocess.pyi b/stdlib/subprocess.pyi index 1013db7ee..b6cc23651 100644 --- a/stdlib/subprocess.pyi +++ b/stdlib/subprocess.pyi @@ -248,7 +248,7 @@ if sys.version_info >= (3, 11): shell: bool = False, cwd: StrOrBytesPath | None = None, env: _ENV | None = None, - universal_newlines: Literal[False, None] = None, + universal_newlines: Literal[False] | None = None, startupinfo: Any = None, creationflags: int = 0, restore_signals: bool = True, @@ -260,7 +260,7 @@ if sys.version_info >= (3, 11): encoding: None = None, errors: None = None, input: ReadableBuffer | None = None, - text: Literal[None, False] = None, + text: Literal[False] | None = None, timeout: float | None = None, user: str | int | None = None, group: str | int | None = None, @@ -452,7 +452,7 @@ elif sys.version_info >= (3, 10): shell: bool = False, cwd: StrOrBytesPath | None = None, env: _ENV | None = None, - universal_newlines: Literal[False, None] = None, + universal_newlines: Literal[False] | None = None, startupinfo: Any = None, creationflags: int = 0, restore_signals: bool = True, @@ -464,7 +464,7 @@ elif sys.version_info >= (3, 10): encoding: None = None, errors: None = None, input: ReadableBuffer | None = None, - text: Literal[None, False] = None, + text: Literal[False] | None = None, timeout: float | None = None, user: str | int | None = None, group: str | int | None = None, @@ -650,7 +650,7 @@ elif sys.version_info >= (3, 9): shell: bool = False, cwd: StrOrBytesPath | None = None, env: _ENV | None = None, - universal_newlines: Literal[False, None] = None, + universal_newlines: Literal[False] | None = None, startupinfo: Any = None, creationflags: int = 0, restore_signals: bool = True, @@ -662,7 +662,7 @@ elif sys.version_info >= (3, 9): encoding: None = None, errors: None = None, input: ReadableBuffer | None = None, - text: Literal[None, False] = None, + text: Literal[False] | None = None, timeout: float | None = None, user: str | int | None = None, group: str | int | None = None, @@ -829,7 +829,7 @@ else: shell: bool = False, cwd: StrOrBytesPath | None = None, env: _ENV | None = None, - universal_newlines: Literal[False, None] = None, + universal_newlines: Literal[False] | None = None, startupinfo: Any = None, creationflags: int = 0, restore_signals: bool = True, @@ -841,7 +841,7 @@ else: encoding: None = None, errors: None = None, input: ReadableBuffer | None = None, - text: Literal[None, False] = None, + text: Literal[False] | None = None, timeout: float | None = None, ) -> CompletedProcess[bytes]: ... @overload @@ -1242,7 +1242,7 @@ if sys.version_info >= (3, 11): shell: bool = False, cwd: StrOrBytesPath | None = None, env: _ENV | None = None, - universal_newlines: Literal[False, None] = None, + universal_newlines: Literal[False] | None = None, startupinfo: Any = None, creationflags: int = 0, restore_signals: bool = True, @@ -1253,7 +1253,7 @@ if sys.version_info >= (3, 11): input: _InputString | None = ..., encoding: None = None, errors: None = None, - text: Literal[None, False] = None, + text: Literal[False] | None = None, user: str | int | None = None, group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, @@ -1428,7 +1428,7 @@ elif sys.version_info >= (3, 10): shell: bool = False, cwd: StrOrBytesPath | None = None, env: _ENV | None = None, - universal_newlines: Literal[False, None] = None, + universal_newlines: Literal[False] | None = None, startupinfo: Any = None, creationflags: int = 0, restore_signals: bool = True, @@ -1439,7 +1439,7 @@ elif sys.version_info >= (3, 10): input: _InputString | None = ..., encoding: None = None, errors: None = None, - text: Literal[None, False] = None, + text: Literal[False] | None = None, user: str | int | None = None, group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, @@ -1608,7 +1608,7 @@ elif sys.version_info >= (3, 9): shell: bool = False, cwd: StrOrBytesPath | None = None, env: _ENV | None = None, - universal_newlines: Literal[False, None] = None, + universal_newlines: Literal[False] | None = None, startupinfo: Any = None, creationflags: int = 0, restore_signals: bool = True, @@ -1619,7 +1619,7 @@ elif sys.version_info >= (3, 9): input: _InputString | None = ..., encoding: None = None, errors: None = None, - text: Literal[None, False] = None, + text: Literal[False] | None = None, user: str | int | None = None, group: str | int | None = None, extra_groups: Iterable[str | int] | None = None, @@ -1769,7 +1769,7 @@ else: shell: bool = False, cwd: StrOrBytesPath | None = None, env: _ENV | None = None, - universal_newlines: Literal[False, None] = None, + universal_newlines: Literal[False] | None = None, startupinfo: Any = None, creationflags: int = 0, restore_signals: bool = True, @@ -1780,7 +1780,7 @@ else: input: _InputString | None = ..., encoding: None = None, errors: None = None, - text: Literal[None, False] = None, + text: Literal[False] | None = None, ) -> bytes: ... @overload def check_output( @@ -1990,14 +1990,14 @@ class Popen(Generic[AnyStr]): shell: bool = False, cwd: StrOrBytesPath | None = None, env: _ENV | None = None, - universal_newlines: Literal[False, None] = None, + universal_newlines: Literal[False] | None = None, startupinfo: Any | None = None, creationflags: int = 0, restore_signals: bool = True, start_new_session: bool = False, pass_fds: Collection[int] = (), *, - text: Literal[None, False] = None, + text: Literal[False] | None = None, encoding: None = None, errors: None = None, user: str | int | None = None, @@ -2175,14 +2175,14 @@ class Popen(Generic[AnyStr]): shell: bool = False, cwd: StrOrBytesPath | None = None, env: _ENV | None = None, - universal_newlines: Literal[False, None] = None, + universal_newlines: Literal[False] | None = None, startupinfo: Any | None = None, creationflags: int = 0, restore_signals: bool = True, start_new_session: bool = False, pass_fds: Collection[int] = (), *, - text: Literal[None, False] = None, + text: Literal[False] | None = None, encoding: None = None, errors: None = None, user: str | int | None = None, @@ -2354,14 +2354,14 @@ class Popen(Generic[AnyStr]): shell: bool = False, cwd: StrOrBytesPath | None = None, env: _ENV | None = None, - universal_newlines: Literal[False, None] = None, + universal_newlines: Literal[False] | None = None, startupinfo: Any | None = None, creationflags: int = 0, restore_signals: bool = True, start_new_session: bool = False, pass_fds: Collection[int] = (), *, - text: Literal[None, False] = None, + text: Literal[False] | None = None, encoding: None = None, errors: None = None, user: str | int | None = None, @@ -2514,14 +2514,14 @@ class Popen(Generic[AnyStr]): shell: bool = False, cwd: StrOrBytesPath | None = None, env: _ENV | None = None, - universal_newlines: Literal[False, None] = None, + universal_newlines: Literal[False] | None = None, startupinfo: Any | None = None, creationflags: int = 0, restore_signals: bool = True, start_new_session: bool = False, pass_fds: Collection[int] = (), *, - text: Literal[None, False] = None, + text: Literal[False] | None = None, encoding: None = None, errors: None = None, ) -> None: ... diff --git a/stubs/Pillow/PIL/EpsImagePlugin.pyi b/stubs/Pillow/PIL/EpsImagePlugin.pyi index 8f62e26f1..49e2f868d 100644 --- a/stubs/Pillow/PIL/EpsImagePlugin.pyi +++ b/stubs/Pillow/PIL/EpsImagePlugin.pyi @@ -9,10 +9,10 @@ from .ImageFile import ImageFile split: Incomplete field: Incomplete if sys.platform == "win32": - gs_binary: Literal["gswin32c", "gswin64c", "gs", False, None] - gs_windows_binary: Literal["gswin32c", "gswin64c", "gs", False, None] + gs_binary: Literal["gswin32c", "gswin64c", "gs", False] | None + gs_windows_binary: Literal["gswin32c", "gswin64c", "gs", False] | None else: - gs_binary: Literal["gs", False, None] + gs_binary: Literal["gs", False] | None gs_windows_binary: None def has_ghostscript(): ... diff --git a/stubs/fpdf2/fpdf/structure_tree.pyi b/stubs/fpdf2/fpdf/structure_tree.pyi index 039e91771..3123d74fc 100644 --- a/stubs/fpdf2/fpdf/structure_tree.pyi +++ b/stubs/fpdf2/fpdf/structure_tree.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete, Unused from collections import defaultdict -from collections.abc import Generator, Iterable +from collections.abc import Iterable, Iterator from .encryption import StandardSecurityHandler from .syntax import PDFArray, PDFObject, PDFString @@ -45,4 +45,4 @@ class StructureTreeBuilder: ) -> tuple[Incomplete, Incomplete]: ... def next_mcid_for_page(self, page_number: int) -> int: ... def empty(self) -> bool: ... - def __iter__(self) -> Generator[Incomplete, None, None]: ... + def __iter__(self) -> Iterator[Incomplete]: ... diff --git a/stubs/openpyxl/openpyxl/cell/cell.pyi b/stubs/openpyxl/openpyxl/cell/cell.pyi index 6ac9c68e3..e92a5b5ee 100644 --- a/stubs/openpyxl/openpyxl/cell/cell.pyi +++ b/stubs/openpyxl/openpyxl/cell/cell.pyi @@ -32,7 +32,7 @@ TYPE_FORMULA_CACHE_STRING: Final = "str" VALID_TYPES: Final[tuple[str, ...]] -def get_type(t: type, value: object) -> Literal["n", "s", "d", "f", None]: ... +def get_type(t: type, value: object) -> Literal["n", "s", "d", "f"] | None: ... def get_time_format(t: _TimeTypes) -> str: ... class Cell(StyleableObject): diff --git a/stubs/pika/pika/adapters/twisted_connection.pyi b/stubs/pika/pika/adapters/twisted_connection.pyi index ab66ddd2f..6d639bb10 100644 --- a/stubs/pika/pika/adapters/twisted_connection.pyi +++ b/stubs/pika/pika/adapters/twisted_connection.pyi @@ -16,7 +16,7 @@ _T = TypeVar("_T") LOGGER: Incomplete -class ClosableDeferredQueue(DeferredQueue[_T], Generic[_T]): # pyright: ignore[reportUntypedBaseClass] +class ClosableDeferredQueue(DeferredQueue[_T], Generic[_T]): # pyright: ignore[reportUntypedBaseClass] # noqa: Y060 closed: Failure | BaseException | None def __init__(self, size: Incomplete | None = ..., backlog: Incomplete | None = ...) -> None: ... # Returns a Deferred with an error if fails. None if success diff --git a/stubs/pyinstaller/PyInstaller/compat.pyi b/stubs/pyinstaller/PyInstaller/compat.pyi index 7e9ed00c5..2ea07f113 100644 --- a/stubs/pyinstaller/PyInstaller/compat.pyi +++ b/stubs/pyinstaller/PyInstaller/compat.pyi @@ -45,7 +45,7 @@ ALL_SUFFIXES: Final[list[str]] architecture: Final[Literal["64bit", "n32bit", "32bit"]] system: Final[Literal["Cygwin", "Linux", "Darwin", "Java", "Windows"]] -machine: Final[Literal["sw_64", "loongarch64", "arm", "intel", "ppc", "mips", "riscv", "s390x", "unknown", None]] +machine: Final[Literal["sw_64", "loongarch64", "arm", "intel", "ppc", "mips", "riscv", "s390x", "unknown"] | None] def is_wine_dll(filename: FileDescriptorOrPath) -> bool: ... @overload diff --git a/stubs/pyinstaller/PyInstaller/depend/imphookapi.pyi b/stubs/pyinstaller/PyInstaller/depend/imphookapi.pyi index 19ba39abf..38d1720fe 100644 --- a/stubs/pyinstaller/PyInstaller/depend/imphookapi.pyi +++ b/stubs/pyinstaller/PyInstaller/depend/imphookapi.pyi @@ -66,5 +66,5 @@ class PostGraphAPI: def add_binaries(self, binaries: TOC | Iterable[tuple[StrOrBytesPath, StrOrBytesPath]]) -> None: ... def add_datas(self, datas: TOC | Iterable[tuple[StrOrBytesPath, StrOrBytesPath]]) -> None: ... def set_module_collection_mode( - self, name: str | None, mode: Literal["pyz", "pyc", "py", "pyz+py", "py+pyz", None] + self, name: str | None, mode: Literal["pyz", "pyc", "py", "pyz+py", "py+pyz"] | None ) -> None: ... diff --git a/stubs/python-xlib/Xlib/support/unix_connect.pyi b/stubs/python-xlib/Xlib/support/unix_connect.pyi index c5ef0e6ad..cc298782b 100644 --- a/stubs/python-xlib/Xlib/support/unix_connect.pyi +++ b/stubs/python-xlib/Xlib/support/unix_connect.pyi @@ -9,11 +9,11 @@ from Xlib._typing import Unused if sys.platform == "darwin": SUPPORTED_PROTOCOLS: Final[tuple[None, Literal["tcp"], Literal["unix"], Literal["darwin"]]] - _Protocol: TypeAlias = Literal[None, "tcp", "unix", "darwin"] + _Protocol: TypeAlias = Literal["tcp", "unix", "darwin"] | None DARWIN_DISPLAY_RE: Final[Pattern[str]] else: SUPPORTED_PROTOCOLS: Final[tuple[None, Literal["tcp"], Literal["unix"]]] - _Protocol: TypeAlias = Literal[None, "tcp", "unix"] + _Protocol: TypeAlias = Literal["tcp", "unix"] | None uname: uname_result DISPLAY_RE: Final[Pattern[str]] diff --git a/stubs/pyxdg/xdg/IniFile.pyi b/stubs/pyxdg/xdg/IniFile.pyi index 83bcf0d55..86f8be93e 100644 --- a/stubs/pyxdg/xdg/IniFile.pyi +++ b/stubs/pyxdg/xdg/IniFile.pyi @@ -238,12 +238,12 @@ class IniFile: list: bool = False, ) -> None: ... def checkExtras(self) -> None: ... - def checkBoolean(self, value: str) -> Literal[1, 2, None]: ... - def checkNumber(self, value: str) -> Literal[1, 2, None]: ... - def checkInteger(self, value: str) -> Literal[1, None]: ... - def checkPoint(self, value: str) -> Literal[1, None]: ... + def checkBoolean(self, value: str) -> Literal[1, 2] | None: ... + def checkNumber(self, value: str) -> Literal[1, 2] | None: ... + def checkInteger(self, value: str) -> Literal[1] | None: ... + def checkPoint(self, value: str) -> Literal[1] | None: ... def checkString(self, value: str) -> Literal[0, 1]: ... - def checkRegex(self, value: str) -> Literal[1, None]: ... + def checkRegex(self, value: str) -> Literal[1] | None: ... def write(self, filename: str | None = None, trusted: bool = False) -> None: ... def set(self, key: str, value: str, group: str | None = None, locale: bool = False) -> None: ... def addGroup(self, group: str) -> None: ... diff --git a/stubs/qrcode/qrcode/main.pyi b/stubs/qrcode/qrcode/main.pyi index df9e11c29..6d77e77a9 100644 --- a/stubs/qrcode/qrcode/main.pyi +++ b/stubs/qrcode/qrcode/main.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete from typing import Generic, NamedTuple, TypeVar, overload -from typing_extensions import Literal, TypeAlias +from typing_extensions import TypeAlias from qrcode.image.base import BaseImage @@ -57,9 +57,9 @@ class QRCode(Generic[GenericImage]): def print_tty(self, out: Incomplete | None = None) -> None: ... def print_ascii(self, out: Incomplete | None = None, tty: bool = False, invert: bool = False): ... @overload - def make_image(self, image_factory: Literal[None] = None, **kwargs) -> GenericImage: ... + def make_image(self, image_factory: None = None, **kwargs) -> GenericImage: ... @overload - def make_image(self, image_factory: type[GenericImageLocal] | None = None, **kwargs) -> GenericImageLocal: ... + def make_image(self, image_factory: type[GenericImageLocal], **kwargs) -> GenericImageLocal: ... def is_constrained(self, row: int, col: int) -> bool: ... def setup_timing_pattern(self) -> None: ... def setup_position_adjust_pattern(self) -> None: ... diff --git a/stubs/seaborn/seaborn/_core/subplots.pyi b/stubs/seaborn/seaborn/_core/subplots.pyi index 593e0f5cb..a3713e2f3 100644 --- a/stubs/seaborn/seaborn/_core/subplots.pyi +++ b/stubs/seaborn/seaborn/_core/subplots.pyi @@ -1,4 +1,4 @@ -from collections.abc import Generator +from collections.abc import Iterator from typing import Any from matplotlib.axes import Axes @@ -15,5 +15,5 @@ class Subplots: figure_kws: dict[str, Any] | None = None, target: Axes | Figure | SubFigure | None = None, ) -> Figure: ... - def __iter__(self) -> Generator[dict[str, Any], None, None]: ... + def __iter__(self) -> Iterator[dict[str, Any]]: ... def __len__(self) -> int: ... diff --git a/stubs/setuptools/pkg_resources/__init__.pyi b/stubs/setuptools/pkg_resources/__init__.pyi index f32c849b1..6dfa2c50f 100644 --- a/stubs/setuptools/pkg_resources/__init__.pyi +++ b/stubs/setuptools/pkg_resources/__init__.pyi @@ -3,7 +3,7 @@ import types import zipimport from _typeshed import Incomplete from abc import ABCMeta -from collections.abc import Callable, Generator, Iterable, Sequence +from collections.abc import Callable, Generator, Iterable, Iterator, Sequence from io import BytesIO from re import Pattern from typing import IO, Any, ClassVar, Protocol, TypeVar, overload, type_check_only @@ -32,7 +32,7 @@ class WorkingSet: def iter_entry_points(self, group: str, name: str | None = None) -> Generator[EntryPoint, None, None]: ... def add_entry(self, entry: str) -> None: ... def __contains__(self, dist: Distribution) -> bool: ... - def __iter__(self) -> Generator[Distribution, None, None]: ... + def __iter__(self) -> Iterator[Distribution]: ... def find(self, req: Requirement) -> Distribution | None: ... def resolve( self, @@ -61,7 +61,7 @@ class Environment: self, search_path: Sequence[str] | None = None, platform: str | None = ..., python: str | None = ... ) -> None: ... def __getitem__(self, project_name: str) -> list[Distribution]: ... - def __iter__(self) -> Generator[str, None, None]: ... + def __iter__(self) -> Iterator[str]: ... def add(self, dist: Distribution) -> None: ... def remove(self, dist: Distribution) -> None: ... def can_add(self, dist: Distribution) -> bool: ... diff --git a/stubs/tensorflow/tensorflow/keras/layers.pyi b/stubs/tensorflow/tensorflow/keras/layers.pyi index 7bb643dd9..6c3824457 100644 --- a/stubs/tensorflow/tensorflow/keras/layers.pyi +++ b/stubs/tensorflow/tensorflow/keras/layers.pyi @@ -38,7 +38,7 @@ class InputSpec: # Most layers have input and output type of just Tensor and when we support default type variables, # maybe worth trying. -class Layer(Generic[_InputT, _OutputT], tf.Module): +class Layer(tf.Module, Generic[_InputT, _OutputT]): # The most general type is _ContainerGeneric[InputSpec] as it really # depends on _InputT. For most Layers it is just InputSpec # though. Maybe describable with HKT?