Nils K
a3c9392331
Add overload to cast for objects ( #4851 )
...
Fixes #4810
2020-12-27 23:46:26 -08:00
Rebecca Chen
61c5667b3f
Fix a Python 2 annotation in shlex. ( #4805 )
...
8d21aa21f2/Lib/shlex.py (L24)
suggests instream can be a string as well.
2020-12-07 14:27:56 -08:00
Eric Traut
c4d8507ff7
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 >
2020-12-06 18:44:18 +01:00
Phillip Huang
3d8a29705e
DeleteJSONDecodeError from Python2's json module ( #4799 )
...
Co-authored-by: Phillip Huang <phillip@dropbox.com >
2020-12-02 13:24:22 -08:00
Lourens Veen
ee69dd4de7
Fix collections.Userstring.encode() ( #4787 )
...
* Revert Python 2 part of ba223399 , the stub was correct
* Describe UserString.encode() return type correctly for Python <3.8
2020-11-24 17:27:29 -08:00
Lourens Veen
ba223399a6
collections.UserString.encode() returns bytes ( #4781 )
2020-11-20 13:14:13 -08:00
Sebastian Rittau
4603728a15
Clean up files with former forced consistency ( #4717 )
...
Replace Text with str in Python 3 code
2020-10-27 07:52:35 +01:00
Shantanu
8581da07fe
builtins: remove unused imports ( #4715 )
...
Co-authored-by: hauntsaninja <>
2020-10-26 08:06:34 +01:00
Shantanu
1dd1b701c9
_typeshed: add SupportsLessThan, SupportsLessThanT ( #4711 )
...
And use it everywhere. Note there seemed to be a discrepancy between
heapq in Python 2 and 3, so I changed that. It should probably be more
widely used within heapq, but leaving that out of scope for this PR.
Co-authored-by: hauntsaninja <>
2020-10-25 15:04:43 -07:00
Vincent Barbaresi
e61f1783fb
add undocumented _heapify_max to heapq stubs ( #4708 )
...
Closes #3926
_heapify_max() existed in Python2 already and hasn't changed in python3 (checked in 3.9)
2020-10-25 12:11:59 -07:00
Shantanu
6ff5b88ca7
typeshed: remove crufty comments ( #4699 )
...
Co-authored-by: hauntsaninja <>
2020-10-23 09:40:06 +02:00
Sebastian Rittau
3de732e188
Split distutils for Python 2 and 3 ( #4685 )
...
Addresses #4679 , but also starts addressing #4674 .
2020-10-22 19:24:17 -07:00
Sebastian Rittau
5927e5ca30
Remove most consistency checks and split builtins.pyi into py2/3 files ( #4686 )
...
Split builtins.pyi in Python 2 and 3 versions
Partly addresses #4674
2020-10-22 13:39:06 -07:00
Shantanu
7e378a7554
PEP 584: add or operators to dict ( #4671 )
...
Co-authored-by: hauntsaninja <>
2020-10-15 13:42:01 +02:00
Shantanu
3a16ebb463
builtins: int can accept __trunc__-able ( #4665 )
...
Refer to https://docs.python.org/3/reference/datamodel.html#object.__trunc__
Fixes https://github.com/python/mypy/issues/9588
Co-authored-by: hauntsaninja <>
2020-10-14 09:47:47 +02:00
Mickaël Schoentgen
67648a7dba
Allow None in value_name argument to winreg.SetValueEx() ( #4663 )
2020-10-13 23:26:11 +02:00
Kevin Wojniak
a19abfd454
Undo int value for winreg SetValue ( #4664 )
2020-10-13 23:23:32 +02:00
Kevin Wojniak
3d89b276d1
Accept int value for winreg SetValue(Ex) ( #4640 )
...
When the type is DWORD an integer is allowed as the value type.
Here is a 3.9 test in cpython as an example: https://github.com/python/cpython/blob/3.9/Lib/test/test_winreg.py#L339
2020-10-12 14:51:48 +02:00
Kaushal Rohit
53367ae18e
Fixed return type for get_request ( #4649 )
...
Fixes #4647
2020-10-12 14:41:11 +02:00
Sebastian Rittau
35f4ade96f
Replace bool.__init__() with __new__() ( #4614 )
...
Fixes #4612
2020-10-09 00:20:03 +02:00
Shantanu
e3889c776e
pep 484: explicit reexport as intended ( #4586 )
...
See discussion on typing-sig.
This doesn't take care of some third_party libraries, will follow up on
those.
Co-authored-by: hauntsaninja <>
2020-09-30 10:04:23 -07:00
Sebastian Rittau
27dfbf68aa
Use __new__ instead of __init__ for some builtin classes ( #4555 )
...
Closes #4514 #2630 #2686
2020-09-30 00:00:06 -07:00
Shantanu
076983eec4
PathLike: make runtime_checkable ( #4582 )
...
I made PathLike a protocol in #4447 , but it should also be
runtime_checkable.
Caught by mypy_primer:
src/werkzeug/utils.py:646: error: Only @runtime_checkable protocols can be used with instance and class checks
2020-09-27 07:50:56 +02:00
Shantanu
d6d2249edc
builtins: rename _LT ( #4579 )
...
Having an obscure type variable name is causing some pretty inscrutable
errors. For instance:
```
xarray/core/utils.py:466: error: Value of type variable "_LT" of "sorted" cannot be "K"
tornado/simple_httpclient.py:324: error: Value of type variable "_LT" of "min" cannot be "Optional[float]"
```
I think having a more descriptive type variable name here is better for
user experience and helps address the "why" of an error.
2020-09-26 07:33:26 +02:00
proost
b1865639c2
set difference strictly ( #3886 )
...
Fixes #1840
2020-09-17 17:49:07 +02:00
Cebtenzzre
1334840323
Make os.fchdir, os.fsync, and os.fdatasync accept FileDescriptorLike ( #4544 )
...
For the fd passed to these functions, CPython accepts not just an int,
but also anything with a fileno() method.
Fixes #4539
2020-09-15 16:30:34 -07:00
Shantanu
dc0b4262c3
builtins: minor improvements ( #4535 )
...
Co-authored-by: hauntsaninja <>
2020-09-13 18:08:48 +02:00
Jake Bailey
f0bbc3bf2d
Add special case for integers raised to a power of 2 ( #4473 )
2020-09-04 21:05:45 -07:00
Jérome Perrin
26ca4e75d8
subprocess: make env accept None also on python2 ( #4504 )
...
This was made for python3 in https://github.com/python/typeshed/pull/1291 but
this is also the case on python2
2020-08-30 20:58:20 -07:00
Jelle Zijlstra
5f9fd3d127
upgrade black version ( #4486 )
...
Manually removed a number of trailing commas to prevent black from unnecessarily
exploding some collections.
2020-08-26 18:36:01 +02:00
Akuli
c065982b7a
support anything with .keys() and __getitem__ in dict.__init__ ( #4470 )
2020-08-24 13:03:38 +02:00
Shantanu
b438ccc3bc
PathLike: change to Protocol ( #4447 )
...
Co-authored-by: hauntsaninja <>
2020-08-16 05:15:51 -07:00
Jukka Lehtosalo
276d0428b9
Avoid false positivies from urlparse (Python 2) ( #4437 )
...
PR #3887 changed some `str` types to `Union[str, unicode]`. The `str`
types were too narrow, but the new types are too general, resulting in
around 80 false positives in a Dropbox internal repository.
I think that it's better to narrow down the types back some to avoid
the false positives, as these are commonly used functions.
Test cases:
```
from urlparse import urlunparse, urlunsplit, urljoin, urlparse, urlsplit
reveal_type(urlunparse(('1', '2', '3', '4', '5', '6'))) # str
reveal_type(urlunparse(['1', '2', '3', '4', '5', '6'])) # str
reveal_type(urlunparse((u'1', '2', '3', '4', '5', '6'))) # unicode
reveal_type(urlunparse([u'1', '2', '3', '4', '5', '6'])) # unicode
reveal_type(urlunsplit(('1', '2', '3', '4', '5'))) # str
reveal_type(urlunsplit(['1', '2', '3', '4', '5'])) # str
reveal_type(urlunsplit((u'1', '2', '3', '4', '5'))) # unicode
reveal_type(urlunsplit([u'1', '2', '3', '4', '5'])) # unicode
reveal_type(urljoin('x', 'y')) # str
reveal_type(urljoin(u'x', 'y')) # unicode
reveal_type(urljoin('x', u'y')) # unicode
reveal_type(urlparse('x').path) # str
reveal_type(urlparse(u'x').path) # str
reveal_type(urlparse(u'x').username) # Optional[str]
reveal_type(urlsplit('x').path) # str
reveal_type(urlsplit(u'x').path) # str
```
2020-08-11 13:03:06 +01:00
Jukka Lehtosalo
866b0c3bf0
ConfigParser: accept readline() that takes no arguments ( #4433 )
...
At runtime readline() is called without arguments, so requiring
an optional argument may result in false positives.
2020-08-10 15:55:32 +01:00
Jukka Lehtosalo
0cd2350595
Add back md5.md5 ( #4432 )
...
This was accidentally removed in #4287 .
2020-08-10 12:52:13 +01:00
Eric Traut
f46fb7ff59
Added some missing type annotations in stdlib stubs. ( #4418 )
...
Co-authored-by: Eric Traut <erictr@microsoft.com >
2020-08-08 20:49:37 +02:00
Adam Hitchcock
3b6925b955
mark deque.rotate arg as having a default ( #4386 )
2020-08-05 17:35:22 -07:00
wouter bolsterlee
83e955b52f
Use correct return type annotation for BaseException.with_traceback ( #4298 )
...
The return type of the BaseException.with_traceback() method [1] is not
specific enough. The return type is guaranteed to be of the same type as
‘self’, which is usually a subclass of BaseException.
In fact, .with_traceback() returns ‘self’:
try:
raise ValueError
except Exception as exc:
assert exc.with_traceback(None) is exc
Fix the annotation to reflect this using the self-type annotation
technique described in PEP484 [2], which is supported by (at least)
mypy [3].
[1] https://docs.python.org/3/library/exceptions.html#BaseException.with_traceback
[2] https://www.python.org/dev/peps/pep-0484/#annotating-instance-and-class-methods
[3] https://github.com/python/mypy/issues/1212
2020-06-30 11:40:25 -07:00
Jelle Zijlstra
0142a87da8
adjust isort config ( #4290 )
...
Fixes #4288 .
- Default imports to THIRD_PARTY, so in effect we merge the FIRST_PARTY and THIRD_PARTY stubs. This means import order is no longer affected by whether typing_extensions is installed locally.
- Treat typing_extensions, _typeshed and some others as standard library modules.
Note that isort master is very different from the latest release; we'll have to do something
different if and when the next isort release comes out.
2020-06-29 00:00:21 -07:00
Jelle Zijlstra
5d553c9584
apply black and isort ( #4287 )
...
* apply black and isort
* move some type ignores
2020-06-28 13:31:00 -07:00
Sebastian Rittau
564a8220f4
Add float.__ceil__ and __floor__ ( #4274 )
...
Closes : #3195
2020-06-26 22:26:39 -07:00
Shantanu
fc8b0ed94e
builtins: remove __class_getitem__ from type ( #4270 )
...
Co-authored-by: hauntsaninja <>
2020-06-26 12:45:22 +02:00
Jia Chen
92fa4e799c
Using dunder parameter name in builtins._SupportsLessThan ( #4264 )
2020-06-25 21:02:00 +02:00
Shantanu
70459abb44
Revert "zip: add some overloads for heterogeneous tuples ( #3830 )" ( #4254 )
...
This reverts commit e857ad6ba9 .
Co-authored-by: hauntsaninja <>
2020-06-25 08:46:02 -07:00
helafumpek
534ebd5051
Change argument type in random.shuffle (python/typeshed#4255) ( #4260 )
...
Fixes #4255
2020-06-24 08:17:13 +02:00
Bruce Merry
fb398b1d59
Use the ReadableBuffer type in more places ( #4245 )
...
This is a follow-up on #4232 . memoryview, hashlib, and hmac are updated
to use ReadableBuffer type instead of their own home-spun unions of
bytes, bytearray and whatever else each use case used. mmap is being
handled in #4244 , and I'll leave BinaryIO for another day (or possibly
another person) because it's going to require some messy code
duplication because the relevant methods are defined in IO[AnyStr].
There's one corner case I'm not quite sure how best to handle: the
documentation for hmac.digest claim that the parmaeters have the same
meanings as in hmac.new, but in CPython the latter has an explicit check
that `key` is bytes or bytearray while the former works with a
memory-view. For now I've matched the documentation.
Also, the documentation for HMAC.update says that `msg` can be any type
supported by hashlib from Python 3.4; but I can't see anything in the
Python 2.7 implementation that would prevent it also taking bytes-like
objects, so I've not tried to treat Python 2 any different to Python 3.
2020-06-22 06:17:24 -07:00
Milap Sheth
66a9a4b5ce
Fix type hint of generator throw method ( #4253 )
...
* Fix type hint of generator throw method
* Incorporated changes from #4252
2020-06-21 15:23:28 -07:00
Luciano Ramalho
1350e710cc
max, min overloads with Protocol: fix #4051 ( #4227 )
2020-06-19 12:37:43 +02:00
Sebastian Rittau
51cf2f51b8
Add IO protocols to _typeshed ( #4230 )
2020-06-14 20:44:48 +02:00
Jelle Zijlstra
d0b85d7efe
remove _types ( #4220 )
2020-06-11 09:10:52 +02:00