Commit Graph

851 Commits

Author SHA1 Message Date
Sebastian Rittau 89d3a55f1a Preparations for the Big Reformat (#4228)
A few comments between imports were removed or moved to the top of the
import block, due to behavioral differences between black and isort. See
psf/black#251 for details.

In two instances @overloads at the top of the file needed to be moved
due to psf/black#1490.
2020-06-14 07:58:26 -07:00
Jelle Zijlstra f67ea2031a xml.etree: use _typeshed (#4221) 2020-06-11 12:41:57 -07:00
Jelle Zijlstra d0b85d7efe remove _types (#4220) 2020-06-11 09:10:52 +02:00
Shantanu ecb43149f7 builtins: NotImplemented is not callable (#4222)
Fixes #3315

Co-authored-by: hauntsaninja <>
2020-06-10 22:05:16 -07:00
Jelle Zijlstra 44a852dff5 Literal: always import from typing_extensions for simplicity (#4219) 2020-06-10 21:23:58 -07:00
Jelle Zijlstra 43e93f803f use _typeshed's Path aliases (#4214) 2020-06-10 20:57:09 -07:00
Jelle Zijlstra ea577cec1f move OpenTextMode and friends to _typeshed (#4213) 2020-06-10 15:36:21 +02:00
Mikhail Golubev 85281b636e Add __class_getitem__ to builtins generified in PEP 585 (#4184)
* Add __class_getitem__ to builtins generified in PEP 585

* Declare types.GenericAlias and use it in __class_getitem__
2020-06-09 20:10:07 -07:00
Phillip Huang f4b23e4a80 Fix cgi.FieldStorage's __iter__ return type (#4209)
Co-authored-by: Phillip Huang <phillip@dropbox.com>
2020-06-08 20:40:14 -07:00
Shantanu f2f65bcf8d profile/cProfile: minor improvements (#4202)
Co-authored-by: hauntsaninja <>
2020-06-08 11:45:55 +02:00
Shantanu df6136c4ac logging: various fixes (#4196)
* logging.disable: update for py37

* RootLogger: fix __init__

* shutdown: add undocumented parameter

* MemoryHandler: add flushOnClose in py36

* NTEventLogHandler: fix dllname type

* makeSocket: add undocumented parameter

* SysLogHandler: fix socktype type

Co-authored-by: hauntsaninja <>
2020-06-07 14:05:29 -07:00
Jaromir Latal 4ab1d6f0ae [stdlib][logging] Make level default in logging.disable for 3.7+ (#4197) 2020-06-07 13:09:22 -07:00
Luciano Ramalho bb9e1a649c using type var to work around List invariance (#4192) 2020-06-06 18:32:15 -07:00
Vegard Stikbakke 34b9cfcdcf curses.bkgset -> bkgdset (#4191) 2020-06-06 08:45:37 -07:00
karl ding 3f141751d7 cProfile: Fix Profile __init__ keyword arguments (#4183)
The CPython _lsprof module implementation uses the keyword arguments
'timer' and 'timeunit' instead of 'custom_timer' and 'time_unit' for
__init__. In profiler_init, the keyword argument parsing looks like the
following:

    static char *kwlist[] = {"timer", "timeunit",
                                   "subcalls", "builtins", 0};

This is the case ever since _lsprof was added in version 2.5.
2020-06-05 07:40:51 -07:00
Shantanu db819480a5 logging: fix argument names (#4181)
* logging: fix argument names

* logging: filter method improvements

Co-authored-by: hauntsaninja <>
2020-06-04 19:32:03 -07:00
Shantanu 7aabfcc65a array: update for py39 (#4180) 2020-06-04 18:32:24 -07:00
Shantanu 5369e813a9 argparse: fix error __init__, add BooleanOptionalAction for py39 (#4144) 2020-06-04 16:00:52 -07:00
Sebastian Rittau 1f82564ee2 Move wsgiref.types to _typeshed.wsgi (#4175)
Re-export the types from wsgiref.types for now to avoid breaking
existing code. wsgiref.types should be removed eventually.

Also, reduce the boilerplate description in _typeshed/wsgi.pyi as it
mirrors the description in _typeshed/__init__.pyi.
2020-06-04 15:38:45 -07:00
Sebastian Rittau eea9be6e73 Add a _typeshed.pyi file and a PathLike alias (#4161) 2020-06-04 14:06:43 +02:00
Sam Bull bd35cd6bf8 Fixes for ssl (#4164) 2020-06-03 21:42:31 +02:00
Sam Bull dd5ef5ed1e Add hostname_checks_common_name attribute to SSLContext (#4160) 2020-06-03 11:19:02 +02:00
Sebastian Rittau a913af9523 flake8: Enable F811 (#4158) 2020-06-02 14:08:54 -07:00
karl ding 43cf0ec870 ssl: Improve SSLContext.options stub (#4152)
In Python 3.6, the SSLContext.options flags were converted from int to
EnumFlag values.

In addition, add the missing OP_ENABLE_MIDDLEBOX_COMPAT constant
introduced in version 3.6.

In addition, add the missing OP_NO_RENEGOTIATION constant introduced in
version 3.7.
2020-06-02 09:19:18 +02:00
karl ding 2137026681 socket: Add missing CAN_BCM option flag constants (#4151)
The SocketCAN BCM option flag constants were added in version 3.9,
and only backported to version 3.8, despite the documentation's claims
of supporting all BCM-related constants starting from version 3.4.

Note: The CAN_FD_FRAME flag option was only introduced in the 4.8.x
kernel series, while the rest of the constants were available since the
Broadcast Manager was mainlined in the kernel as part of the SocketCAN
patches.
2020-06-01 01:21:54 +02:00
Jelle Zijlstra adeda24fce open: introduce concrete return types (#4146)
* make io classes inherit from typing IO classes

This makes these classes usable if type annotations are given as "IO"
or "TextIO". In the future, we'll then be able to move open() to
return a concrete class instead (#3951).

* open: introduce concrete return types

Fixes #3951.

We use the values of the "mode" and "buffering" arguments to figure out
the concrete type open() will return at runtime. (Compare the CPython
code in https://github.com/python/cpython/blob/master/Modules/_io/_iomodule.c#L231.)
2020-06-01 00:48:12 +02:00
Markus Pielmeier b7d9a4a584 Add support for __pow__ with pow() builtin (#4109) 2020-05-30 15:38:19 -07:00
Shantanu de2c2947fe windows: fix splitunc param name (#4143)
Co-authored-by: hauntsaninja <>
2020-05-29 20:37:19 -04:00
karl ding 09821cd9ca Add typing for CAN_J1939 sockets (#4141)
Add typing for CAN_J1939 sockets implementing support for the SAE J1939
protocol. This is available in Python 3.9+ on Linux 5.4+.
2020-05-29 12:33:47 +02:00
Rune Tynan a1953431ff Move oem_(decode, encode) to be 3.6+ (#4140) 2020-05-28 18:57:32 -07:00
Brian Wellington 0bed1d3956 socket.create_connection source_address is optional. (#4133) 2020-05-28 19:56:11 +02:00
Jelle Zijlstra c80622fbb9 remove type ignores about python/mypy#5027 (#4119)
The mypy issue got fixed by the good people of mypy. I did have to add an
override for __enter__ similar to what we're doing in #4082.
2020-05-28 09:51:54 -07:00
Ilaï Deutel 846d922df2 More precise return types for open(), Path.open(), bz2.open(), etc. (#3371)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
2020-05-28 09:20:23 -07:00
Jelle Zijlstra 0cffa59e57 use a Protocol for str.format_map() (#4122)
Fixes #3824
2020-05-28 13:27:57 +02:00
Gregory P. Smith a9d5a1ed99 hmac digestmod is no longer Optional as of 3.8. (#3367) 2020-05-28 09:24:32 +02:00
Shantanu eca19f00fb bdb: various fixes (#4127) 2020-05-27 21:42:45 -07:00
Shantanu e8d0cadf7b aifc: update for py39 (#4126)
Co-authored-by: hauntsaninja <>
2020-05-27 21:42:32 -07:00
Shantanu 22fd5e916a wsgiref: fix arg name, make close an instance variable (#4123)
Co-authored-by: hauntsaninja <>
2020-05-27 21:06:11 -07:00
Shantanu c988348179 ctypes: fix arg name on windows (#4111)
Co-authored-by: hauntsaninja <>
2020-05-27 20:21:45 -07:00
Brad Solomon ddb47deb27 Allow Union[unicode, str] rather than just str in several places (#3887)
* Allow unicode objects throughout urlparse.py

Functions such as `urlparse()`, if given a unicode object,
will happily return a ParseResult of unicode components.

Relatedly, functions like `unquote()` will accept any of
bytes/str/unicode and return an object of the same type
or a composite containing that type.

* Allow unicode in several places in Thread

`name` and `kwargs` to Thread.__init__ function perfectly
well with unicode, not just str.

Note: the .name attribute will always be str even
if the constructor is passed something else, since
__init__ calls:

    self.__name = str(name or _newname())

* Use typing.AnyStr properly

...rather than defining a new TypeVar unncessarily.

* Use typing.Text properly

Text is behaviorally equivalent to Union[str, unicode]
for Python 2 argument types.

* Remove outdated import & definition

* [check file consistent] copy changes to _dummy_threading.pyi
2020-05-27 19:52:14 -07:00
Michael H a1c6566abe [Add stub entry for logging._srcfile] (#3840)
- While this appears to be private, it's also documented as available
  to set here: https://docs.python.org/3/howto/logging.html#optimization
  - Did *not* update `logging.logThreads` et al to match the
  documentation as it may be more appropriate to update the
  documentation to set to `False` rather than to `0` based on how these
  are used

Type further narrowed based on known type of a parameter to
`os.normcase`
2020-05-27 19:42:33 -07:00
Shantanu fd203e663e py39: add PEP 616 methods (#4090) 2020-05-27 19:24:25 -07:00
Shantanu 02e1a68a56 argparse: add Action.format_usage (#4114)
Co-authored-by: hauntsaninja <>
2020-05-27 18:36:01 -07:00
Rune Tynan d51e13ad80 Add stubtest to Travis for windows (#4113) 2020-05-27 18:33:07 -07:00
Rune Tynan 0c1babd288 Make _codecs pass stubtest on windows (#4107) 2020-05-27 19:36:41 +02:00
Batuhan Taskaya 53ede5967b is_tarfile accepts pathlike (#3804) 2020-05-27 17:21:55 +02:00
Rune Tynan 7ac284f641 Add _pydecimal and _decimal stubs (#4003) 2020-05-27 10:10:51 +02:00
Rune Tynan f1d96d97fe Fix stubtest failures for msvcrt on windows (#4095) 2020-05-27 10:05:33 +02:00
Zhiming Wang edb7dc1171 xml.etree.ElementTree: add support for os.PathLike for py36+ (#4097)
xml.etree.ElementTree uses open on filenames (e.g. [1]), so os.PathLike has
been supported as filenames since Python 3.6.

[1] https://github.com/python/cpython/blob/285ff63351bb5a42099527c283f65434e761be83/Lib/xml/etree/ElementTree.py#L584
2020-05-27 10:04:12 +02:00
Rune Tynan 9b4eb8c90b Fix stubtest failures for select on windows (#4099) 2020-05-27 09:57:06 +02:00