Skip to content

Commit

Permalink
Removed unused import symbols from stdlib stubs and fixed a few other…
Browse files Browse the repository at this point in the history
… errors detected by pyright. I did a similar pass several months ago; these were introduced since then. (#4803)

Co-authored-by: Eric Traut <[email protected]>
  • Loading branch information
erictraut and msfterictraut authored Dec 6, 2020
1 parent 3d8a297 commit c4d8507
Show file tree
Hide file tree
Showing 19 changed files with 26 additions and 20 deletions.
6 changes: 5 additions & 1 deletion stdlib/2/inspect.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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]: ...
2 changes: 1 addition & 1 deletion stdlib/2and3/contextlib.pyi
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion stdlib/2and3/plistlib.pyi
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion stdlib/2and3/socket.pyi
Original file line number Diff line number Diff line change
@@ -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 -----
Expand Down
2 changes: 1 addition & 1 deletion stdlib/3/asyncio/futures.pyi
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion stdlib/3/asyncio/trsock.pyi
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion stdlib/3/concurrent/futures/_base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion stdlib/3/distutils/command/upload.pyi
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
4 changes: 2 additions & 2 deletions stdlib/3/distutils/dist.pyi
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
1 change: 0 additions & 1 deletion stdlib/3/functools.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ from typing import (
Mapping,
NamedTuple,
Optional,
Protocol,
Sequence,
Tuple,
Type,
Expand Down
2 changes: 1 addition & 1 deletion stdlib/3/importlib/util.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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]] = ...,
Expand Down
6 changes: 5 additions & 1 deletion stdlib/3/inspect.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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]: ...
2 changes: 1 addition & 1 deletion stdlib/3/ntpath.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion stdlib/3/os/path.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion stdlib/3/pathlib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion stdlib/3/posixpath.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion stdlib/3/resource.pyi
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion stdlib/3/statistics.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion stdlib/3/urllib/request.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c4d8507

Please sign in to comment.