Skip to content

Third-party stubs: fix several fictitious type aliases #7958

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions stubs/Pillow/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
PIL.FpxImagePlugin
PIL.ImageQt.ImageQt
PIL.ImageQt.QImage # Does exist at runtime usually, but stubtest can't see it
PIL.ImageQt.QPixmap # Does exist at runtime usually, but stubtest can't see it
PIL.MicImagePlugin
PIL.WmfImagePlugin.WmfHandler
6 changes: 3 additions & 3 deletions stubs/Pillow/PIL/ImageQt.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from typing import Any
from typing_extensions import Literal
from typing_extensions import Literal, TypeAlias

from .Image import Image

QImage = Any # imported from either of {PyQt6,PySide6,PyQt5,PySide2}.QtGui
QPixmap = Any
QImage: TypeAlias = Any # imported from either of {PyQt6,PySide6,PyQt5,PySide2}.QtGui
QPixmap: TypeAlias = Any

qt_versions: Any
qt_is_installed: bool
Expand Down
18 changes: 9 additions & 9 deletions stubs/SQLAlchemy/sqlalchemy/ext/mypy/names.pyi
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
from typing import Any
from typing_extensions import TypeAlias

from ...util import symbol

ClassDef = Any # from mypy.nodes
Expression = Any # from mypy.nodes
MemberExpr = Any # from mypy.nodes
NameExpr = Any # from mypy.nodes
SymbolNode = Any # from mypy.nodes
TypeInfo = Any # from mypy.nodes
StrExpr = Any # from mypy.nodes
SemanticAnalyzerPluginInterface = Any # from mypy.plugin
UnboundType = Any # from mypy.types
ClassDef: TypeAlias = Any # from mypy.nodes
Expression: TypeAlias = Any # from mypy.nodes
MemberExpr: TypeAlias = Any # from mypy.nodes
NameExpr: TypeAlias = Any # from mypy.nodes
SymbolNode: TypeAlias = Any # from mypy.nodes
TypeInfo: TypeAlias = Any # from mypy.nodes
SemanticAnalyzerPluginInterface: TypeAlias = Any # from mypy.plugin
UnboundType: TypeAlias = Any # from mypy.types

COLUMN: symbol
RELATIONSHIP: symbol
Expand Down
24 changes: 12 additions & 12 deletions stubs/SQLAlchemy/sqlalchemy/ext/mypy/util.pyi
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
from collections.abc import Iterable, Iterator
from typing import Any, TypeVar, overload
from typing_extensions import TypeAlias

CallExpr = Any # from mypy.nodes
Context = Any # from mypy.nodes
Expression = Any # from mypy.nodes
JsonDict = Any # from mypy.nodes
NameExpr = Any # from mypy.nodes
Statement = Any # from mypy.nodes
TypeInfo = Any # from mypy.nodes
AttributeContext = Any # from mypy.plugin
ClassDefContext = Any # from mypy.plugin
DynamicClassDefContext = Any # from mypy.plugin
SemanticAnalyzerPluginInterface = Any # from mypy.plugin
Type = Any # from mypy.types
CallExpr: TypeAlias = Any # from mypy.nodes
Context: TypeAlias = Any # from mypy.nodes
Expression: TypeAlias = Any # from mypy.nodes
JsonDict: TypeAlias = Any # from mypy.nodes
NameExpr: TypeAlias = Any # from mypy.nodes
Statement: TypeAlias = Any # from mypy.nodes
TypeInfo: TypeAlias = Any # from mypy.nodes
ClassDefContext: TypeAlias = Any # from mypy.plugin
DynamicClassDefContext: TypeAlias = Any # from mypy.plugin
SemanticAnalyzerPluginInterface: TypeAlias = Any # from mypy.plugin
Type: TypeAlias = Any # from mypy.types

_TArgType = TypeVar("_TArgType", bound=CallExpr | NameExpr)

Expand Down
1 change: 1 addition & 0 deletions stubs/google-cloud-ndb/@tests/requirements-stubtest.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
protobuf==3.20.1
6 changes: 3 additions & 3 deletions stubs/google-cloud-ndb/google/cloud/ndb/model.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ class UserNotFoundError(exceptions.Error): ...
class _NotEqualMixin:
def __ne__(self, other: object) -> bool: ...

DirectionT: TypeAlias = Literal["asc", "desc"]
_Direction: TypeAlias = Literal["asc", "desc"]

class IndexProperty(_NotEqualMixin):
def __new__(cls: type[Self], name: str, direction: DirectionT) -> Self: ...
def __new__(cls: type[Self], name: str, direction: _Direction) -> Self: ...
@property
def name(self) -> str: ...
@property
def direction(self) -> DirectionT: ...
def direction(self) -> _Direction: ...
def __eq__(self, other: object) -> bool: ...
def __hash__(self) -> int: ...

Expand Down
6 changes: 3 additions & 3 deletions stubs/ldap3/ldap3/utils/asn1.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from typing import Any
from typing_extensions import TypeAlias

# Enable when pyasn1 gets stubs:
# from pyasn1.codec.ber.encoder import AbstractItemEncoder, BooleanEncoder
AbstractItemEncoder = Any
BooleanEncoder = Any
# from pyasn1.codec.ber.encoder import AbstractItemEncoder
AbstractItemEncoder: TypeAlias = Any

CLASSES: Any

Expand Down
9 changes: 5 additions & 4 deletions stubs/python-jose/jose/backends/_asn1.pyi
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
from typing import Any
from typing_extensions import TypeAlias

# Enable when pyasn1 gets stubs:
# from pyasn1.type import univ
Sequence = Any
_Sequence: TypeAlias = Any

RSA_ENCRYPTION_ASN1_OID: str

class RsaAlgorithmIdentifier(Sequence):
class RsaAlgorithmIdentifier(_Sequence):
componentType: Any

class PKCS8PrivateKey(Sequence):
class PKCS8PrivateKey(_Sequence):
componentType: Any

class PublicKeyInfo(Sequence):
class PublicKeyInfo(_Sequence):
componentType: Any

def rsa_private_key_pkcs8_to_pkcs1(pkcs8_key): ...
Expand Down
5 changes: 2 additions & 3 deletions stubs/requests/requests/adapters.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ from urllib3.util import retry

from . import cookies, exceptions, models, structures, utils

PreparedRequest = models.PreparedRequest
Response = models.Response
PoolManager = poolmanager.PoolManager
proxy_from_url = poolmanager.proxy_from_url
Expand Down Expand Up @@ -40,7 +39,7 @@ class BaseAdapter:
def __init__(self) -> None: ...
def send(
self,
request: PreparedRequest,
request: models.PreparedRequest,
stream: bool = ...,
timeout: None | float | tuple[float, float] | tuple[float, None] = ...,
verify: bool | str = ...,
Expand Down Expand Up @@ -69,7 +68,7 @@ class HTTPAdapter(BaseAdapter):
def proxy_headers(self, proxy): ...
def send(
self,
request: PreparedRequest,
request: models.PreparedRequest,
stream: bool = ...,
timeout: None | float | tuple[float, float] | tuple[float, None] = ...,
verify: bool | str = ...,
Expand Down
1 change: 0 additions & 1 deletion stubs/requests/requests/utils.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ from typing import Any, AnyStr
from . import compat, cookies, exceptions, structures

OrderedDict = compat.OrderedDict
RequestsCookieJar = cookies.RequestsCookieJar
cookiejar_from_dict = cookies.cookiejar_from_dict
CaseInsensitiveDict = structures.CaseInsensitiveDict
InvalidURL = exceptions.InvalidURL
Expand Down
6 changes: 3 additions & 3 deletions stubs/setuptools/pkg_resources/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ from collections.abc import Callable, Generator, Iterable, Sequence
from typing import IO, Any, TypeVar, overload
from typing_extensions import TypeAlias

LegacyVersion: TypeAlias = Any # from packaging.version
Version: TypeAlias = Any # from packaging.version
_LegacyVersion: TypeAlias = Any # from packaging.version
_Version: TypeAlias = Any # from packaging.version

_T = TypeVar("_T")
_NestedStr: TypeAlias = str | Iterable[str | Iterable[Any]]
Expand Down Expand Up @@ -262,7 +262,7 @@ empty_provider: EmptyProvider
class FileMetadata(EmptyProvider, IResourceProvider):
def __init__(self, path_to_pkg_info: str) -> None: ...

def parse_version(v: str) -> Version | LegacyVersion: ...
def parse_version(v: str) -> _Version | _LegacyVersion: ...
def yield_lines(strs: _NestedStr) -> Generator[str, None, None]: ...
def split_sections(strs: _NestedStr) -> Generator[tuple[str | None, str], None, None]: ...
def safe_name(name: str) -> str: ...
Expand Down
24 changes: 12 additions & 12 deletions stubs/typed-ast/typed_ast/ast27.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ PyCF_ONLY_AST: int

# ast classes

identifier = str
_identifier: TypeAlias = str

class AST:
_attributes: tuple[str, ...]
Expand Down Expand Up @@ -55,14 +55,14 @@ class stmt(AST):
col_offset: int

class FunctionDef(stmt):
name: identifier
name: _identifier
args: arguments
body: list[stmt]
decorator_list: list[expr]
type_comment: str | None

class ClassDef(stmt):
name: identifier
name: _identifier
bases: list[expr]
body: list[stmt]
decorator_list: list[expr]
Expand Down Expand Up @@ -133,7 +133,7 @@ class Import(stmt):
names: list[alias]

class ImportFrom(stmt):
module: identifier | None
module: _identifier | None
names: list[alias]
level: int | None

Expand All @@ -143,7 +143,7 @@ class Exec(stmt):
locals: expr | None

class Global(stmt):
names: list[identifier]
names: list[_identifier]

class Expr(stmt):
value: expr
Expand Down Expand Up @@ -245,7 +245,7 @@ class Str(expr):

class Attribute(expr):
value: expr
attr: identifier
attr: _identifier
ctx: expr_context

class Subscript(expr):
Expand All @@ -254,7 +254,7 @@ class Subscript(expr):
ctx: expr_context

class Name(expr):
id: identifier
id: _identifier
ctx: expr_context

class List(expr):
Expand Down Expand Up @@ -319,18 +319,18 @@ class ExceptHandler(AST):

class arguments(AST):
args: list[expr]
vararg: identifier | None
kwarg: identifier | None
vararg: _identifier | None
kwarg: _identifier | None
defaults: list[expr]
type_comments: list[str | None]

class keyword(AST):
arg: identifier
arg: _identifier
value: expr

class alias(AST):
name: identifier
asname: identifier | None
name: _identifier
asname: _identifier | None

class TypeIgnore(AST):
lineno: int
28 changes: 14 additions & 14 deletions stubs/typed-ast/typed_ast/ast3.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ PyCF_ONLY_AST: int

# ast classes

identifier = str
_identifier: TypeAlias = str

class AST:
_attributes: tuple[str, ...]
Expand Down Expand Up @@ -55,23 +55,23 @@ class stmt(AST):
col_offset: int

class FunctionDef(stmt):
name: identifier
name: _identifier
args: arguments
body: list[stmt]
decorator_list: list[expr]
returns: expr | None
type_comment: str | None

class AsyncFunctionDef(stmt):
name: identifier
name: _identifier
args: arguments
body: list[stmt]
decorator_list: list[expr]
returns: expr | None
type_comment: str | None

class ClassDef(stmt):
name: identifier
name: _identifier
bases: list[expr]
keywords: list[keyword]
body: list[stmt]
Expand Down Expand Up @@ -151,15 +151,15 @@ class Import(stmt):
names: list[alias]

class ImportFrom(stmt):
module: identifier | None
module: _identifier | None
names: list[alias]
level: int | None

class Global(stmt):
names: list[identifier]
names: list[_identifier]

class Nonlocal(stmt):
names: list[identifier]
names: list[_identifier]

class Expr(stmt):
value: expr
Expand Down Expand Up @@ -276,7 +276,7 @@ class Ellipsis(expr): ...

class Attribute(expr):
value: expr
attr: identifier
attr: _identifier
ctx: expr_context

class Subscript(expr):
Expand All @@ -289,7 +289,7 @@ class Starred(expr):
ctx: expr_context

class Name(expr):
id: identifier
id: _identifier
ctx: expr_context

class List(expr):
Expand Down Expand Up @@ -349,7 +349,7 @@ class comprehension(AST):

class ExceptHandler(AST):
type: expr | None
name: identifier | None
name: _identifier | None
body: list[stmt]
lineno: int
col_offset: int
Expand All @@ -363,19 +363,19 @@ class arguments(AST):
defaults: list[expr]

class arg(AST):
arg: identifier
arg: _identifier
annotation: expr | None
lineno: int
col_offset: int
type_comment: str | None

class keyword(AST):
arg: identifier | None
arg: _identifier | None
value: expr

class alias(AST):
name: identifier
asname: identifier | None
name: _identifier
asname: _identifier | None

class withitem(AST):
context_expr: expr
Expand Down
3 changes: 0 additions & 3 deletions stubs/urllib3/urllib3/connection.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ BaseSSLError = ssl.SSLError

ConnectTimeoutError = exceptions.ConnectTimeoutError
SystemTimeWarning = exceptions.SystemTimeWarning
SecurityWarning = exceptions.SecurityWarning
match_hostname = ssl_match_hostname.match_hostname
resolve_cert_reqs = ssl_.resolve_cert_reqs
resolve_ssl_version = ssl_.resolve_ssl_version
Expand Down Expand Up @@ -58,5 +57,3 @@ class VerifiedHTTPSConnection(HTTPSConnection):
auto_open: Any
is_verified: Any
def connect(self): ...

UnverifiedHTTPSConnection = HTTPSConnection
Loading