mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-21 03:11:16 +08:00
Clean up a few Python 2 remnants (#8452)
This commit is contained in:
@@ -435,8 +435,6 @@ Some further tips for good type hints:
|
||||
* avoid invariant collection types (`list`, `dict`) in argument
|
||||
positions, in favor of covariant types like `Mapping` or `Sequence`;
|
||||
* avoid union return types: https://github.com/python/mypy/issues/1693;
|
||||
* in Python 2, whenever possible, use `unicode` if that's the only
|
||||
possible type, and `Text` if it can be either `unicode` or `bytes`;
|
||||
* use platform checks like `if sys.platform == 'win32'` to denote
|
||||
platform-dependent APIs;
|
||||
* use mypy error codes for mypy-specific `# type: ignore` annotations,
|
||||
|
||||
@@ -28,22 +28,4 @@ extra_standard_library = [
|
||||
"genericpath",
|
||||
"opcode",
|
||||
"pyexpat",
|
||||
# Python 2 modules
|
||||
"__builtin__",
|
||||
"cookielib",
|
||||
"cStringIO",
|
||||
"httplib",
|
||||
"mimetools",
|
||||
"rfc822",
|
||||
"thread",
|
||||
"urllib2",
|
||||
"urlparse",
|
||||
"BaseHTTPServer",
|
||||
"Queue",
|
||||
"SimpleHTTPServer",
|
||||
"SocketServer",
|
||||
"StringIO",
|
||||
"UserDict",
|
||||
"UserList",
|
||||
"UserString",
|
||||
]
|
||||
|
||||
@@ -75,7 +75,7 @@ class _Stream(_WritableStream, _ReadableStream, Protocol): ...
|
||||
# bytes is the raw form and str is the cooked form.
|
||||
# In the long run, both should become template parameters maybe?
|
||||
# There *are* bytes->bytes and str->str encodings in the standard library.
|
||||
# They are much more common in Python 2 than in Python 3.
|
||||
# They were much more common in Python 2 than in Python 3.
|
||||
|
||||
class _Encoder(Protocol):
|
||||
def __call__(self, input: str, errors: str = ...) -> tuple[bytes, int]: ... # signature of Codec().encode
|
||||
|
||||
@@ -50,7 +50,7 @@ class croniter(Iterator[Any]):
|
||||
day_or: bool = ...,
|
||||
max_years_between_matches: int | None = ...,
|
||||
is_prev: bool = ...,
|
||||
hash_id: str | bytes | None = ..., # unicode not accepted on python 2
|
||||
hash_id: str | bytes | None = ...,
|
||||
) -> None: ...
|
||||
# Most return value depend on ret_type, which can be passed in both as a method argument and as
|
||||
# a constructor argument.
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
Depends on pytype being installed.
|
||||
|
||||
If pytype is installed:
|
||||
1. For every pyi, do nothing if it is in pytype_exclude_list.txt or is
|
||||
Python 2-only.
|
||||
1. For every pyi, do nothing if it is in pytype_exclude_list.txt.
|
||||
2. Otherwise, call 'pytype.io.parse_pyi'.
|
||||
Option two will load the file and all the builtins, typeshed dependencies. This
|
||||
will also discover incorrect usage of imported modules.
|
||||
|
||||
Reference in New Issue
Block a user