Removed unused import symbols from stdlib stubs and fixed a few other errors detected by pyright. I did a similar pass several months ago; these were introduced since then. (#4803)

Co-authored-by: Eric Traut <erictr@microsoft.com>
This commit is contained in:
Eric Traut
2020-12-06 09:44:18 -08:00
committed by GitHub
parent 3d8a29705e
commit c4d8507ff7
19 changed files with 26 additions and 20 deletions

View File

@@ -116,10 +116,14 @@ def currentframe(depth: int = ...) -> FrameType: ...
def stack(context: int = ...) -> List[_FrameInfo]: ...
def trace(context: int = ...) -> List[_FrameInfo]: ...
# Create private type alias to avoid conflict with symbol of same
# name created in Attribute class.
_Object = object
class Attribute(NamedTuple):
name: str
kind: str
defining_class: type
object: object
object: _Object
def classify_class_attrs(cls: type) -> List[Attribute]: ...

View File

@@ -1,6 +1,6 @@
import sys
from types import TracebackType
from typing import IO, Any, Callable, ContextManager, Generic, Iterable, Iterator, Optional, Type, TypeVar, overload
from typing import IO, Any, Callable, ContextManager, Iterable, Iterator, Optional, Type, TypeVar, overload
if sys.version_info >= (3, 5):
from typing import AsyncContextManager, AsyncIterator

View File

@@ -1,5 +1,5 @@
import sys
from typing import IO, Any, Dict as DictT, Mapping, MutableMapping, Optional, Text, Type, TypeVar, Union, overload
from typing import IO, Any, Dict as DictT, Mapping, MutableMapping, Optional, Text, Type, Union
if sys.version_info >= (3,):
from enum import Enum

View File

@@ -1,5 +1,5 @@
import sys
from typing import Any, BinaryIO, Iterable, List, Optional, Sequence, Text, TextIO, Tuple, TypeVar, Union, overload
from typing import Any, BinaryIO, Iterable, List, Optional, Text, TextIO, Tuple, TypeVar, Union, overload
from typing_extensions import Literal
# ----- Constants -----

View File

@@ -1,6 +1,6 @@
import sys
from concurrent.futures._base import Error, Future as _ConcurrentFuture
from typing import Any, Awaitable, Callable, Generator, Iterable, List, Optional, Tuple, Type, TypeVar, Union
from typing import Any, Awaitable, Callable, Generator, Iterable, List, Optional, Tuple, TypeVar, Union
from .events import AbstractEventLoop

View File

@@ -1,7 +1,7 @@
import socket
import sys
from types import TracebackType
from typing import Any, BinaryIO, Iterable, List, NoReturn, Optional, Sequence, Tuple, Type, Union, overload
from typing import Any, BinaryIO, Iterable, List, NoReturn, Optional, Tuple, Type, Union, overload
if sys.version_info >= (3, 8):
# These are based in socket, maybe move them out into _typeshed.pyi or such

View File

@@ -2,7 +2,6 @@ import sys
import threading
from abc import abstractmethod
from logging import Logger
from types import TracebackType
from typing import (
Any,
Callable,

View File

@@ -1,5 +1,5 @@
from distutils.config import PyPIRCCommand
from typing import ClassVar, List, Optional, Tuple
from typing import ClassVar, List
class upload(PyPIRCCommand):
description: ClassVar[str]

View File

@@ -1,9 +1,9 @@
from _typeshed import AnyPath, SupportsWrite
from distutils.cmd import Command
from typing import IO, Any, AnyStr, Dict, Iterable, List, Mapping, Optional, Tuple, Type, Union
from typing import IO, Any, Dict, Iterable, List, Mapping, Optional, Tuple, Type, Union
class DistributionMetadata:
def __init__(self, path: Optional[Union[int, AnyPath]] = ...): ...
def __init__(self, path: Optional[Union[int, AnyPath]] = ...) -> None: ...
name: Optional[str]
version: Optional[str]
author: Optional[str]

View File

@@ -10,7 +10,6 @@ from typing import (
Mapping,
NamedTuple,
Optional,
Protocol,
Sequence,
Tuple,
Type,

View File

@@ -25,7 +25,7 @@ def spec_from_loader(
) -> importlib.machinery.ModuleSpec: ...
def spec_from_file_location(
name: str,
location: Union[str, bytes, os.PathLike],
location: Union[str, bytes, os.PathLike[str], os.PathLike[bytes]],
*,
loader: Optional[importlib.abc.Loader] = ...,
submodule_search_locations: Optional[List[str]] = ...,

View File

@@ -296,10 +296,14 @@ def getgeneratorlocals(generator: Generator[Any, Any, Any]) -> Dict[str, Any]: .
# TODO can we be more specific than "object"?
def getcoroutinelocals(coroutine: object) -> Dict[str, Any]: ...
# Create private type alias to avoid conflict with symbol of same
# name created in Attribute class.
_Object = object
class Attribute(NamedTuple):
name: str
kind: str
defining_class: type
object: object
object: _Object
def classify_class_attrs(cls: type) -> List[Attribute]: ...

View File

@@ -2,7 +2,7 @@ import os
import sys
from _typeshed import AnyPath, BytesPath, StrPath
from genericpath import exists as exists
from typing import Any, AnyStr, Callable, List, Optional, Sequence, Tuple, TypeVar, overload
from typing import Any, AnyStr, Optional, Sequence, Tuple, TypeVar, overload
_T = TypeVar("_T")

View File

@@ -2,7 +2,7 @@ import os
import sys
from _typeshed import AnyPath, BytesPath, StrPath
from genericpath import exists as exists
from typing import Any, AnyStr, Callable, List, Optional, Sequence, Tuple, TypeVar, overload
from typing import Any, AnyStr, Optional, Sequence, Tuple, TypeVar, overload
_T = TypeVar("_T")

View File

@@ -3,7 +3,7 @@ import sys
from _typeshed import OpenBinaryMode, OpenBinaryModeReading, OpenBinaryModeUpdating, OpenBinaryModeWriting, OpenTextMode
from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper
from types import TracebackType
from typing import IO, Any, BinaryIO, Generator, List, Optional, Sequence, TextIO, Tuple, Type, TypeVar, Union, overload
from typing import IO, Any, BinaryIO, Generator, List, Optional, Sequence, Tuple, Type, TypeVar, Union, overload
from typing_extensions import Literal
if sys.version_info >= (3, 9):

View File

@@ -2,7 +2,7 @@ import os
import sys
from _typeshed import AnyPath, BytesPath, StrPath
from genericpath import exists as exists
from typing import Any, AnyStr, Callable, List, Optional, Sequence, Tuple, TypeVar, overload
from typing import Any, AnyStr, Optional, Sequence, Tuple, TypeVar, overload
_T = TypeVar("_T")

View File

@@ -1,5 +1,5 @@
import sys
from typing import NamedTuple, Optional, Tuple, overload
from typing import NamedTuple, Tuple, overload
RLIMIT_AS: int
RLIMIT_CORE: int

View File

@@ -2,7 +2,7 @@ import sys
from _typeshed import SupportsLessThanT
from decimal import Decimal
from fractions import Fraction
from typing import Any, Hashable, Iterable, List, Optional, Protocol, SupportsFloat, Type, TypeVar, Union
from typing import Any, Hashable, Iterable, List, Optional, SupportsFloat, Type, TypeVar, Union
_T = TypeVar("_T")
# Most functions in this module accept homogeneous collections of one of these types

View File

@@ -153,7 +153,7 @@ class HTTPPasswordMgrWithPriorAuth(HTTPPasswordMgrWithDefaultRealm):
def is_authenticated(self, authuri: str) -> bool: ...
class AbstractBasicAuthHandler:
rx: ClassVar[Pattern] # undocumented
rx: ClassVar[Pattern[str]] # undocumented
def __init__(self, password_mgr: Optional[HTTPPasswordMgr] = ...) -> None: ...
def http_error_auth_reqed(self, authreq: str, host: str, req: Request, headers: Mapping[str, str]) -> None: ...
def http_request(self, req: Request) -> Request: ... # undocumented