From 0949e9e90d44abd9a2e81226edb2a5731306dafd Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 16 Jan 2022 14:29:13 -0800 Subject: [PATCH] remove quoted strings (#6933) --- stdlib/@python2/__builtin__.pyi | 2 +- stdlib/@python2/builtins.pyi | 2 +- stdlib/tkinter/__init__.pyi | 4 ++-- stdlib/types.pyi | 24 +++++++------------ stdlib/zoneinfo/__init__.pyi | 2 +- .../cryptography/x509/__init__.pyi | 2 +- stubs/polib/polib.pyi | 6 ++--- 7 files changed, 18 insertions(+), 24 deletions(-) diff --git a/stdlib/@python2/__builtin__.pyi b/stdlib/@python2/__builtin__.pyi index 45eee82cc..532301014 100644 --- a/stdlib/@python2/__builtin__.pyi +++ b/stdlib/@python2/__builtin__.pyi @@ -60,7 +60,7 @@ _T2 = TypeVar("_T2") _T3 = TypeVar("_T3") _T4 = TypeVar("_T4") _T5 = TypeVar("_T5") -_TT = TypeVar("_TT", bound="type") +_TT = TypeVar("_TT", bound=type) class object: __doc__: str | None diff --git a/stdlib/@python2/builtins.pyi b/stdlib/@python2/builtins.pyi index 45eee82cc..532301014 100644 --- a/stdlib/@python2/builtins.pyi +++ b/stdlib/@python2/builtins.pyi @@ -60,7 +60,7 @@ _T2 = TypeVar("_T2") _T3 = TypeVar("_T3") _T4 = TypeVar("_T4") _T5 = TypeVar("_T5") -_TT = TypeVar("_TT", bound="type") +_TT = TypeVar("_TT", bound=type) class object: __doc__: str | None diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index 8ce9707e2..bac6fe4d6 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -101,9 +101,9 @@ class EventType(str, Enum): VirtualEvent: str Visibility: str -_W = TypeVar("_W", bound="Misc") +_W = TypeVar("_W", bound=Misc) # Events considered covariant because you should never assign to event.widget. -_W_co = TypeVar("_W_co", covariant=True, bound="Misc") +_W_co = TypeVar("_W_co", covariant=True, bound=Misc) class Event(Generic[_W_co]): serial: int diff --git a/stdlib/types.pyi b/stdlib/types.pyi index 5cad8badf..cf30cbd64 100644 --- a/stdlib/types.pyi +++ b/stdlib/types.pyi @@ -64,8 +64,6 @@ LambdaType = FunctionType @final class CodeType: - """Create a code object. Not for the faint of heart.""" - co_argcount: int if sys.version_info >= (3, 8): co_posonlyargcount: int @@ -262,19 +260,15 @@ class CoroutineType(Coroutine[_T_co, _T_contra, _V_co]): def throw(self, __typ: BaseException, __val: None = ..., __tb: TracebackType | None = ...) -> _T_co: ... class _StaticFunctionType: - """Fictional type to correct the type of MethodType.__func__. - - FunctionType is a descriptor, so mypy follows the descriptor protocol and - converts MethodType.__func__ back to MethodType (the return type of - FunctionType.__get__). But this is actually a special case; MethodType is - implemented in C and its attribute access doesn't go through - __getattribute__. - - By wrapping FunctionType in _StaticFunctionType, we get the right result; - similar to wrapping a function in staticmethod() at runtime to prevent it - being bound as a method. - """ - + # Fictional type to correct the type of MethodType.__func__. + # FunctionType is a descriptor, so mypy follows the descriptor protocol and + # converts MethodType.__func__ back to MethodType (the return type of + # FunctionType.__get__). But this is actually a special case; MethodType is + # implemented in C and its attribute access doesn't go through + # __getattribute__. + # By wrapping FunctionType in _StaticFunctionType, we get the right result; + # similar to wrapping a function in staticmethod() at runtime to prevent it + # being bound as a method. def __get__(self, obj: object | None, type: type | None) -> FunctionType: ... @final diff --git a/stdlib/zoneinfo/__init__.pyi b/stdlib/zoneinfo/__init__.pyi index 36e483953..864392510 100644 --- a/stdlib/zoneinfo/__init__.pyi +++ b/stdlib/zoneinfo/__init__.pyi @@ -3,7 +3,7 @@ from _typeshed import Self, StrPath from datetime import tzinfo from typing import Any, Iterable, Protocol, Sequence -_T = typing.TypeVar("_T", bound="ZoneInfo") +_T = typing.TypeVar("_T", bound=ZoneInfo) class _IOBytes(Protocol): def read(self, __size: int) -> bytes: ... diff --git a/stubs/cryptography/cryptography/x509/__init__.pyi b/stubs/cryptography/cryptography/x509/__init__.pyi index 7c58e2a7e..97875e1f1 100644 --- a/stubs/cryptography/cryptography/x509/__init__.pyi +++ b/stubs/cryptography/cryptography/x509/__init__.pyi @@ -282,7 +282,7 @@ class UniformResourceIdentifier(GeneralName): class ExtensionType(metaclass=ABCMeta): oid: ObjectIdentifier -_T = TypeVar("_T", bound="ExtensionType") +_T = TypeVar("_T", bound=ExtensionType) class Extension(Generic[_T]): critical: bool diff --git a/stubs/polib/polib.pyi b/stubs/polib/polib.pyi index 4b6d57d9e..cd5dbaf66 100644 --- a/stubs/polib/polib.pyi +++ b/stubs/polib/polib.pyi @@ -2,9 +2,9 @@ import textwrap from typing import IO, Any, Callable, Generic, Text, TypeVar, overload from typing_extensions import SupportsIndex -_TB = TypeVar("_TB", bound="_BaseEntry") -_TP = TypeVar("_TP", bound="POFile") -_TM = TypeVar("_TM", bound="MOFile") +_TB = TypeVar("_TB", bound=_BaseEntry) +_TP = TypeVar("_TP", bound=POFile) +_TM = TypeVar("_TM", bound=MOFile) default_encoding: str