-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Split stdlib into Python 2 and 3 versions #5442
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
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ac9c037
Split stdlib into Python 2 and 3 versions
srittau b8cfb86
Remove @python2/configparser.pyi (called ConfigParser in Py 2)
srittau 11891c6
Fix mypy warning in genericpath
srittau 23c5e29
Just use type ignore
srittau 8ceb2c4
Update CONTRIBUTING
srittau a8dc8ba
Add another type ignore
srittau 8f50ec2
Merge branch 'master' into split-py2-py3
srittau fa1158c
Merge branch 'master' into split-py2-py3
srittau 405f7f1
Apply changes to py_compile and ssl to @python2
srittau 96ce542
Empty commit to trigger CI
Akuli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import sys | ||
| from typing import List | ||
|
|
||
| class _Feature: | ||
| def __init__(self, optionalRelease: sys._version_info, mandatoryRelease: sys._version_info, compiler_flag: int) -> None: ... | ||
| def getOptionalRelease(self) -> sys._version_info: ... | ||
| def getMandatoryRelease(self) -> sys._version_info: ... | ||
| compiler_flag: int | ||
|
|
||
| absolute_import: _Feature | ||
| division: _Feature | ||
| generators: _Feature | ||
| nested_scopes: _Feature | ||
| print_function: _Feature | ||
| unicode_literals: _Feature | ||
| with_statement: _Feature | ||
| if sys.version_info >= (3, 0): | ||
| barry_as_FLUFL: _Feature | ||
|
|
||
| if sys.version_info >= (3, 5): | ||
| generator_stop: _Feature | ||
|
|
||
| if sys.version_info >= (3, 7): | ||
| annotations: _Feature | ||
|
|
||
| all_feature_names: List[str] # undocumented | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from typing import Any | ||
|
|
||
| def __getattr__(name: str) -> Any: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import sys | ||
| from _typeshed import SupportsLessThan | ||
| from typing import Callable, MutableSequence, Optional, Sequence, TypeVar | ||
|
|
||
| _T = TypeVar("_T") | ||
|
|
||
| if sys.version_info >= (3, 10): | ||
| def bisect_left( | ||
| a: Sequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ..., *, key: Optional[Callable[[_T], SupportsLessThan]] = ... | ||
| ) -> int: ... | ||
| def bisect_right( | ||
| a: Sequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ..., *, key: Optional[Callable[[_T], SupportsLessThan]] = ... | ||
| ) -> int: ... | ||
| def insort_left( | ||
| a: MutableSequence[_T], | ||
| x: _T, | ||
| lo: int = ..., | ||
| hi: Optional[int] = ..., | ||
| *, | ||
| key: Optional[Callable[[_T], SupportsLessThan]] = ..., | ||
| ) -> None: ... | ||
| def insort_right( | ||
| a: MutableSequence[_T], | ||
| x: _T, | ||
| lo: int = ..., | ||
| hi: Optional[int] = ..., | ||
| *, | ||
| key: Optional[Callable[[_T], SupportsLessThan]] = ..., | ||
| ) -> None: ... | ||
|
|
||
| else: | ||
| def bisect_left(a: Sequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> int: ... | ||
| def bisect_right(a: Sequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> int: ... | ||
| def insort_left(a: MutableSequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> None: ... | ||
| def insort_right(a: MutableSequence[_T], x: _T, lo: int = ..., hi: Optional[int] = ...) -> None: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| import codecs | ||
| import sys | ||
| from typing import Any, Callable, Dict, Optional, Text, Tuple, Union | ||
|
|
||
| # For convenience: | ||
| _Handler = Callable[[Exception], Tuple[Text, int]] | ||
| _String = Union[bytes, str] | ||
| _Errors = Union[str, Text, None] | ||
| if sys.version_info >= (3, 0): | ||
| _Decodable = bytes | ||
| _Encodable = str | ||
| else: | ||
| _Decodable = Union[bytes, Text] | ||
| _Encodable = Union[bytes, Text] | ||
|
|
||
| # This type is not exposed; it is defined in unicodeobject.c | ||
| class _EncodingMap(object): | ||
| def size(self) -> int: ... | ||
|
|
||
| _MapT = Union[Dict[int, int], _EncodingMap] | ||
|
|
||
| def register(__search_function: Callable[[str], Any]) -> None: ... | ||
| def register_error(__errors: Union[str, Text], __handler: _Handler) -> None: ... | ||
| def lookup(__encoding: Union[str, Text]) -> codecs.CodecInfo: ... | ||
| def lookup_error(__name: Union[str, Text]) -> _Handler: ... | ||
| def decode(obj: Any, encoding: Union[str, Text] = ..., errors: _Errors = ...) -> Any: ... | ||
| def encode(obj: Any, encoding: Union[str, Text] = ..., errors: _Errors = ...) -> Any: ... | ||
| def charmap_build(__map: Text) -> _MapT: ... | ||
| def ascii_decode(__data: _Decodable, __errors: _Errors = ...) -> Tuple[Text, int]: ... | ||
| def ascii_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ... | ||
|
|
||
| if sys.version_info < (3, 2): | ||
| def charbuffer_encode(__data: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ... | ||
|
|
||
| def charmap_decode(__data: _Decodable, __errors: _Errors = ..., __mapping: Optional[_MapT] = ...) -> Tuple[Text, int]: ... | ||
| def charmap_encode(__str: _Encodable, __errors: _Errors = ..., __mapping: Optional[_MapT] = ...) -> Tuple[bytes, int]: ... | ||
| def escape_decode(__data: _String, __errors: _Errors = ...) -> Tuple[str, int]: ... | ||
| def escape_encode(__data: bytes, __errors: _Errors = ...) -> Tuple[bytes, int]: ... | ||
| def latin_1_decode(__data: _Decodable, __errors: _Errors = ...) -> Tuple[Text, int]: ... | ||
| def latin_1_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ... | ||
| def raw_unicode_escape_decode(__data: _String, __errors: _Errors = ...) -> Tuple[Text, int]: ... | ||
| def raw_unicode_escape_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ... | ||
| def readbuffer_encode(__data: _String, __errors: _Errors = ...) -> Tuple[bytes, int]: ... | ||
| def unicode_escape_decode(__data: _String, __errors: _Errors = ...) -> Tuple[Text, int]: ... | ||
| def unicode_escape_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ... | ||
|
|
||
| if sys.version_info < (3, 8): | ||
| def unicode_internal_decode(__obj: _String, __errors: _Errors = ...) -> Tuple[Text, int]: ... | ||
| def unicode_internal_encode(__obj: _String, __errors: _Errors = ...) -> Tuple[bytes, int]: ... | ||
|
|
||
| def utf_16_be_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ... | ||
| def utf_16_be_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ... | ||
| def utf_16_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ... | ||
| def utf_16_encode(__str: _Encodable, __errors: _Errors = ..., __byteorder: int = ...) -> Tuple[bytes, int]: ... | ||
| def utf_16_ex_decode( | ||
| __data: _Decodable, __errors: _Errors = ..., __byteorder: int = ..., __final: int = ... | ||
| ) -> Tuple[Text, int, int]: ... | ||
| def utf_16_le_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ... | ||
| def utf_16_le_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ... | ||
| def utf_32_be_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ... | ||
| def utf_32_be_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ... | ||
| def utf_32_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ... | ||
| def utf_32_encode(__str: _Encodable, __errors: _Errors = ..., __byteorder: int = ...) -> Tuple[bytes, int]: ... | ||
| def utf_32_ex_decode( | ||
| __data: _Decodable, __errors: _Errors = ..., __byteorder: int = ..., __final: int = ... | ||
| ) -> Tuple[Text, int, int]: ... | ||
| def utf_32_le_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ... | ||
| def utf_32_le_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ... | ||
| def utf_7_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ... | ||
| def utf_7_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ... | ||
| def utf_8_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ... | ||
| def utf_8_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ... | ||
|
|
||
| if sys.platform == "win32": | ||
| def mbcs_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ... | ||
| def mbcs_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ... | ||
| if sys.version_info >= (3, 0): | ||
| def code_page_decode(__codepage: int, __data: bytes, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ... | ||
| def code_page_encode(__code_page: int, __str: Text, __errors: _Errors = ...) -> Tuple[bytes, int]: ... | ||
| if sys.version_info >= (3, 6): | ||
| def oem_decode(__data: bytes, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ... | ||
| def oem_encode(__str: Text, __errors: _Errors = ...) -> Tuple[bytes, int]: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import sys | ||
| from typing import Any, Iterable, Iterator, List, Optional, Protocol, Sequence, Text, Type, Union | ||
|
|
||
| QUOTE_ALL: int | ||
| QUOTE_MINIMAL: int | ||
| QUOTE_NONE: int | ||
| QUOTE_NONNUMERIC: int | ||
|
|
||
| class Error(Exception): ... | ||
|
|
||
| class Dialect: | ||
| delimiter: str | ||
| quotechar: Optional[str] | ||
| escapechar: Optional[str] | ||
| doublequote: bool | ||
| skipinitialspace: bool | ||
| lineterminator: str | ||
| quoting: int | ||
| strict: int | ||
| def __init__(self) -> None: ... | ||
|
|
||
| _DialectLike = Union[str, Dialect, Type[Dialect]] | ||
|
|
||
| class _reader(Iterator[List[str]]): | ||
| dialect: Dialect | ||
| line_num: int | ||
| if sys.version_info >= (3, 0): | ||
| def __next__(self) -> List[str]: ... | ||
| else: | ||
| def next(self) -> List[str]: ... | ||
|
|
||
| class _writer: | ||
| dialect: Dialect | ||
|
|
||
| if sys.version_info >= (3, 5): | ||
| def writerow(self, row: Iterable[Any]) -> Any: ... | ||
| def writerows(self, rows: Iterable[Iterable[Any]]) -> None: ... | ||
| else: | ||
| def writerow(self, row: Sequence[Any]) -> Any: ... | ||
| def writerows(self, rows: Iterable[Sequence[Any]]) -> None: ... | ||
|
|
||
| class _Writer(Protocol): | ||
| def write(self, s: str) -> Any: ... | ||
|
|
||
| def writer(csvfile: _Writer, dialect: _DialectLike = ..., **fmtparams: Any) -> _writer: ... | ||
| def reader(csvfile: Iterable[Text], dialect: _DialectLike = ..., **fmtparams: Any) -> _reader: ... | ||
| def register_dialect(name: str, dialect: Any = ..., **fmtparams: Any) -> None: ... | ||
| def unregister_dialect(name: str) -> None: ... | ||
| def get_dialect(name: str) -> Dialect: ... | ||
| def list_dialects() -> List[str]: ... | ||
| def field_size_limit(new_limit: int = ...) -> int: ... |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These Python 3 version checks might be worth removing at some point, at least if we can script it easily.