diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index be83c23c3..225032b9d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -72,7 +72,7 @@ jobs: python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"] fail-fast: false env: - PYRIGHT_VERSION: 1.1.192 # Must match pyright_test.py. + PYRIGHT_VERSION: 1.1.204 # Must match pyright_test.py. steps: - uses: actions/checkout@v2 - uses: jakebailey/pyright-action@v1 diff --git a/stdlib/bz2.pyi b/stdlib/bz2.pyi index 69f13e496..6b0c02543 100644 --- a/stdlib/bz2.pyi +++ b/stdlib/bz2.pyi @@ -88,7 +88,7 @@ def open( newline: str | None = ..., ) -> BZ2File | TextIO: ... -class BZ2File(BaseStream, IO[bytes]): +class BZ2File(BaseStream, IO[bytes]): # type: ignore # argument disparities between base classes def __enter__(self: Self) -> Self: ... if sys.version_info >= (3, 9): @overload diff --git a/stdlib/email/parser.pyi b/stdlib/email/parser.pyi index 574c927ee..edff6f5b4 100644 --- a/stdlib/email/parser.pyi +++ b/stdlib/email/parser.pyi @@ -1,10 +1,12 @@ import email.feedparser from email.message import Message from email.policy import Policy -from typing import BinaryIO, Callable, TextIO +from typing import BinaryIO, Callable, TextIO, TypeVar -FeedParser = email.feedparser.FeedParser -BytesFeedParser = email.feedparser.BytesFeedParser +_M = TypeVar("_M", bound=Message) + +FeedParser = email.feedparser.FeedParser[_M] +BytesFeedParser = email.feedparser.BytesFeedParser[_M] class Parser: def __init__(self, _class: Callable[[], Message] | None = ..., *, policy: Policy = ...) -> None: ... diff --git a/stdlib/http/client.pyi b/stdlib/http/client.pyi index 1558f6ff4..a8d32e328 100644 --- a/stdlib/http/client.pyi +++ b/stdlib/http/client.pyi @@ -78,7 +78,7 @@ class HTTPMessage(email.message.Message): def parse_headers(fp: io.BufferedIOBase, _class: Callable[[], email.message.Message] = ...) -> HTTPMessage: ... -class HTTPResponse(io.BufferedIOBase, BinaryIO): +class HTTPResponse(io.BufferedIOBase, BinaryIO): # type: ignore # argument disparities between base classes msg: HTTPMessage headers: HTTPMessage version: int diff --git a/stdlib/importlib/machinery.pyi b/stdlib/importlib/machinery.pyi index b73f9c527..acce98850 100644 --- a/stdlib/importlib/machinery.pyi +++ b/stdlib/importlib/machinery.pyi @@ -129,10 +129,10 @@ class FileFinder(importlib.abc.PathEntryFinder): cls, *loader_details: tuple[importlib.abc.Loader, list[str]] ) -> Callable[[str], importlib.abc.PathEntryFinder]: ... -class SourceFileLoader(importlib.abc.FileLoader, importlib.abc.SourceLoader): +class SourceFileLoader(importlib.abc.FileLoader, importlib.abc.SourceLoader): # type: ignore # argument disparities def set_data(self, path: importlib.abc._Path, data: bytes, *, _mode: int = ...) -> None: ... -class SourcelessFileLoader(importlib.abc.FileLoader, importlib.abc.SourceLoader): ... +class SourcelessFileLoader(importlib.abc.FileLoader, importlib.abc.SourceLoader): ... # type: ignore # argument disparities class ExtensionFileLoader(importlib.abc.ExecutionLoader): def __init__(self, name: str, path: importlib.abc._Path) -> None: ... diff --git a/stdlib/io.pyi b/stdlib/io.pyi index 50452917c..12abe0673 100644 --- a/stdlib/io.pyi +++ b/stdlib/io.pyi @@ -63,7 +63,7 @@ class BufferedIOBase(IOBase): def read(self, __size: int | None = ...) -> bytes: ... def read1(self, __size: int = ...) -> bytes: ... -class FileIO(RawIOBase, BinaryIO): +class FileIO(RawIOBase, BinaryIO): # type: ignore # argument disparities between the base classes mode: str name: StrOrBytesPath | int # type: ignore[assignment] def __init__( @@ -75,7 +75,7 @@ class FileIO(RawIOBase, BinaryIO): def read(self, __size: int = ...) -> bytes: ... def __enter__(self: Self) -> Self: ... -class BytesIO(BufferedIOBase, BinaryIO): +class BytesIO(BufferedIOBase, BinaryIO): # type: ignore # argument disparities between the base classes def __init__(self, initial_bytes: bytes = ...) -> None: ... # BytesIO does not contain a "name" field. This workaround is necessary # to allow BytesIO sub-classes to add this field, as it is defined @@ -89,7 +89,7 @@ class BytesIO(BufferedIOBase, BinaryIO): else: def read1(self, __size: int | None) -> bytes: ... # type: ignore[override] -class BufferedReader(BufferedIOBase, BinaryIO): +class BufferedReader(BufferedIOBase, BinaryIO): # type: ignore # argument disparities between base classes def __enter__(self: Self) -> Self: ... def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ... def peek(self, __size: int = ...) -> bytes: ... @@ -98,7 +98,7 @@ class BufferedReader(BufferedIOBase, BinaryIO): else: def read1(self, __size: int) -> bytes: ... # type: ignore[override] -class BufferedWriter(BufferedIOBase, BinaryIO): +class BufferedWriter(BufferedIOBase, BinaryIO): # type: ignore # argument disparities between base classes def __enter__(self: Self) -> Self: ... def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ... def write(self, __buffer: ReadableBuffer) -> int: ... @@ -130,7 +130,7 @@ class TextIOBase(IOBase): def read(self, __size: int | None = ...) -> str: ... def tell(self) -> int: ... -class TextIOWrapper(TextIOBase, TextIO): +class TextIOWrapper(TextIOBase, TextIO): # type: ignore # argument disparities between base classes def __init__( self, buffer: IO[bytes], diff --git a/stdlib/lzma.pyi b/stdlib/lzma.pyi index e4bd977d7..9993776a3 100644 --- a/stdlib/lzma.pyi +++ b/stdlib/lzma.pyi @@ -64,7 +64,7 @@ class LZMACompressor: class LZMAError(Exception): ... -class LZMAFile(io.BufferedIOBase, IO[bytes]): +class LZMAFile(io.BufferedIOBase, IO[bytes]): # type: ignore # argument disparities between base classes def __init__( self, filename: _PathOrFile | None = ..., diff --git a/stdlib/unittest/mock.pyi b/stdlib/unittest/mock.pyi index 72d0bab95..fc0ceb014 100644 --- a/stdlib/unittest/mock.pyi +++ b/stdlib/unittest/mock.pyi @@ -406,7 +406,7 @@ if sys.version_info >= (3, 8): await_args_list: _CallList class AsyncMagicMixin(MagicMixin): def __init__(self, *args: Any, **kw: Any) -> None: ... - class AsyncMock(AsyncMockMixin, AsyncMagicMixin, Mock): ... + class AsyncMock(AsyncMockMixin, AsyncMagicMixin, Mock): ... # type: ignore # argument disparities between base classes class MagicProxy: name: Any diff --git a/stubs/SQLAlchemy/sqlalchemy/dialects/sybase/pyodbc.pyi b/stubs/SQLAlchemy/sqlalchemy/dialects/sybase/pyodbc.pyi index 3940f1f66..2c870d14c 100644 --- a/stubs/SQLAlchemy/sqlalchemy/dialects/sybase/pyodbc.pyi +++ b/stubs/SQLAlchemy/sqlalchemy/dialects/sybase/pyodbc.pyi @@ -10,7 +10,7 @@ class _SybNumeric_pyodbc(sqltypes.Numeric): class SybaseExecutionContext_pyodbc(SybaseExecutionContext): def set_ddl_autocommit(self, connection, value) -> None: ... -class SybaseDialect_pyodbc(PyODBCConnector, SybaseDialect): +class SybaseDialect_pyodbc(PyODBCConnector, SybaseDialect): # type: ignore # argument disparities between base classes supports_statement_cache: bool colspecs: Any @classmethod diff --git a/stubs/SQLAlchemy/sqlalchemy/orm/context.pyi b/stubs/SQLAlchemy/sqlalchemy/orm/context.pyi index bc123f007..b5fc3cd00 100644 --- a/stubs/SQLAlchemy/sqlalchemy/orm/context.pyi +++ b/stubs/SQLAlchemy/sqlalchemy/orm/context.pyi @@ -75,7 +75,7 @@ class ORMFromStatementCompileState(ORMCompileState): @classmethod def create_for_statement(cls, statement_container, compiler, **kw): ... -class ORMSelectCompileState(ORMCompileState, SelectState): +class ORMSelectCompileState(ORMCompileState, SelectState): # type: ignore # argument disparities between base classes multi_row_eager_loaders: bool compound_eager_adapter: Any correlate: Any diff --git a/stubs/SQLAlchemy/sqlalchemy/sql/schema.pyi b/stubs/SQLAlchemy/sqlalchemy/sql/schema.pyi index 66b4197d6..b7c82d82a 100644 --- a/stubs/SQLAlchemy/sqlalchemy/sql/schema.pyi +++ b/stubs/SQLAlchemy/sqlalchemy/sql/schema.pyi @@ -37,7 +37,7 @@ class Table(DialectKWArgs, SchemaItem, TableClause): def tometadata(self, metadata, schema=..., referred_schema_fn: Any | None = ..., name: Any | None = ...): ... def to_metadata(self, metadata, schema=..., referred_schema_fn: Any | None = ..., name: Any | None = ...): ... -class Column(DialectKWArgs, SchemaItem, ColumnClause): +class Column(DialectKWArgs, SchemaItem, ColumnClause): # type: ignore # argument disparities between base classes __visit_name__: str inherit_cache: bool key: Any diff --git a/stubs/SQLAlchemy/sqlalchemy/sql/sqltypes.pyi b/stubs/SQLAlchemy/sqlalchemy/sql/sqltypes.pyi index f26c34139..6e47dd97d 100644 --- a/stubs/SQLAlchemy/sqlalchemy/sql/sqltypes.pyi +++ b/stubs/SQLAlchemy/sqlalchemy/sql/sqltypes.pyi @@ -155,7 +155,7 @@ class SchemaType(SchemaEventTarget): def create(self, bind: Any | None = ..., checkfirst: bool = ...) -> None: ... def drop(self, bind: Any | None = ..., checkfirst: bool = ...) -> None: ... -class Enum(Emulated, String, SchemaType): +class Enum(Emulated, String, SchemaType): # type: ignore # argument disparities between base classes __visit_name__: str def __init__(self, *enums, **kw) -> None: ... @property diff --git a/stubs/babel/babel/support.pyi b/stubs/babel/babel/support.pyi index 3755073d5..a9e393225 100644 --- a/stubs/babel/babel/support.pyi +++ b/stubs/babel/babel/support.pyi @@ -79,7 +79,7 @@ class NullTranslations(gettext.NullTranslations): ugettext: Any ungettext: Any -class Translations(NullTranslations, gettext.GNUTranslations): +class Translations(NullTranslations, gettext.GNUTranslations): # type: ignore # argument disparities between base classes DEFAULT_DOMAIN: str domain: Any def __init__(self, fp: Any | None = ..., domain: Any | None = ...) -> None: ... diff --git a/stubs/beautifulsoup4/bs4/builder/_lxml.pyi b/stubs/beautifulsoup4/bs4/builder/_lxml.pyi index 492848911..9133e6a17 100644 --- a/stubs/beautifulsoup4/bs4/builder/_lxml.pyi +++ b/stubs/beautifulsoup4/bs4/builder/_lxml.pyi @@ -37,7 +37,7 @@ class LXMLTreeBuilderForXML(TreeBuilder): def comment(self, content) -> None: ... def test_fragment_to_document(self, fragment): ... -class LXMLTreeBuilder(HTMLTreeBuilder, LXMLTreeBuilderForXML): +class LXMLTreeBuilder(HTMLTreeBuilder, LXMLTreeBuilderForXML): # type: ignore # argument disparities between base classes NAME: Any ALTERNATE_NAMES: Any features: Any diff --git a/stubs/boto/boto/auth.pyi b/stubs/boto/boto/auth.pyi index 2dc77949c..3a588d27e 100644 --- a/stubs/boto/boto/auth.pyi +++ b/stubs/boto/boto/auth.pyi @@ -64,7 +64,7 @@ class HmacAuthV4Handler(AuthHandler, HmacKeys): def signature(self, http_request, string_to_sign): ... def add_auth(self, req, **kwargs): ... -class S3HmacAuthV4Handler(HmacAuthV4Handler, AuthHandler): +class S3HmacAuthV4Handler(HmacAuthV4Handler, AuthHandler): # type: ignore # argument disparities between base classes capability: Any region_name: Any def __init__(self, *args, **kwargs) -> None: ... diff --git a/stubs/mock/mock/mock.pyi b/stubs/mock/mock/mock.pyi index e61862bf8..0765ea745 100644 --- a/stubs/mock/mock/mock.pyi +++ b/stubs/mock/mock/mock.pyi @@ -268,7 +268,7 @@ class AsyncMockMixin(Base): class AsyncMagicMixin(MagicMixin): def __init__(self, *args: Any, **kw: Any) -> None: ... -class AsyncMock(AsyncMockMixin, AsyncMagicMixin, Mock): ... +class AsyncMock(AsyncMockMixin, AsyncMagicMixin, Mock): ... # type: ignore # argument disparities between base classes class MagicProxy(Base): name: str diff --git a/stubs/regex/regex/_regex.pyi b/stubs/regex/regex/_regex.pyi index 0e5915400..bb9de6f1a 100644 --- a/stubs/regex/regex/_regex.pyi +++ b/stubs/regex/regex/_regex.pyi @@ -6,7 +6,6 @@ _T = TypeVar("_T") @final class Pattern(Generic[AnyStr]): - pattern: AnyStr flags: int groups: int diff --git a/stubs/regex/regex/regex.pyi b/stubs/regex/regex/regex.pyi index 69812a26c..a8bfd3bbe 100644 --- a/stubs/regex/regex/regex.pyi +++ b/stubs/regex/regex/regex.pyi @@ -149,6 +149,6 @@ def cache_all(value: None) -> bool: ... def escape(pattern: AnyStr, special_only: bool = ..., literal_spaces: bool = ...) -> AnyStr: ... def template(pattern: AnyStr | _regex.Pattern[AnyStr], flags: int = ...) -> _regex.Pattern[AnyStr]: ... -Pattern = _regex.Pattern -Match = _regex.Match +Pattern = _regex.Pattern[AnyStr] +Match = _regex.Match[AnyStr] Regex = compile diff --git a/stubs/requests/requests/models.pyi b/stubs/requests/requests/models.pyi index 957a0e074..db4e4214c 100644 --- a/stubs/requests/requests/models.pyi +++ b/stubs/requests/requests/models.pyi @@ -1,13 +1,15 @@ import datetime from json import JSONDecoder -from typing import Any, Callable, Iterator, Text, Type +from typing import Any, Callable, Iterator, Text, Type, TypeVar from . import auth, cookies, exceptions, hooks, status_codes, structures, utils from .cookies import RequestsCookieJar from .packages.urllib3 import exceptions as urllib3_exceptions, fields, filepost, util +_VT = TypeVar("_VT") + default_hooks = hooks.default_hooks -CaseInsensitiveDict = structures.CaseInsensitiveDict +CaseInsensitiveDict = structures.CaseInsensitiveDict[_VT] HTTPBasicAuth = auth.HTTPBasicAuth cookiejar_from_dict = cookies.cookiejar_from_dict get_cookie_header = cookies.get_cookie_header diff --git a/stubs/requests/requests/sessions.pyi b/stubs/requests/requests/sessions.pyi index 645b5df8a..c01e32a6b 100644 --- a/stubs/requests/requests/sessions.pyi +++ b/stubs/requests/requests/sessions.pyi @@ -5,6 +5,9 @@ from . import adapters, auth as _auth, compat, cookies, exceptions, hooks, model from .models import Response from .packages.urllib3 import _collections +_KT = TypeVar("_KT") +_VT = TypeVar("_VT") + _BaseAdapter = adapters.BaseAdapter OrderedDict = compat.OrderedDict cookiejar_from_dict = cookies.cookiejar_from_dict @@ -23,8 +26,8 @@ TooManyRedirects = exceptions.TooManyRedirects InvalidSchema = exceptions.InvalidSchema ChunkedEncodingError = exceptions.ChunkedEncodingError ContentDecodingError = exceptions.ContentDecodingError -RecentlyUsedContainer = _collections.RecentlyUsedContainer -CaseInsensitiveDict = structures.CaseInsensitiveDict +RecentlyUsedContainer = _collections.RecentlyUsedContainer[_KT, _VT] +CaseInsensitiveDict = structures.CaseInsensitiveDict[_VT] HTTPAdapter = adapters.HTTPAdapter requote_uri = utils.requote_uri get_environ_proxies = utils.get_environ_proxies diff --git a/tests/pyright_test.py b/tests/pyright_test.py index 6a10d14e0..5a34ff8c6 100755 --- a/tests/pyright_test.py +++ b/tests/pyright_test.py @@ -5,7 +5,7 @@ import subprocess import sys from pathlib import Path -_PYRIGHT_VERSION = "1.1.192" # Must match tests.yml. +_PYRIGHT_VERSION = "1.1.204" # Must match .github/workflows/tests.yml. _WELL_KNOWN_FILE = Path("tests", "pyright_test.py")