Daniel Farley
955e9c7da4
Unify file descriptor definitions ( #3584 )
...
The _types module can house any common type defintions used throughout
the rest of typeshed to keep defintions in sync.
First candidate is file descriptors where anything with `fileno()`
method is accepted. There were several different implementations in
various files that can be unified.
2020-01-08 17:25:36 -08:00
hauntsaninja
1efc1baaf7
stdtypes: update for py38 ( #3580 )
2020-01-06 20:57:34 -08:00
Jason
a1331accbe
Update int.from_bytes to allow more than sequences ( #3571 )
...
`int.from_bytes` supports both iterables of ints and objects that define
__bytes__'. As an example `int.from_bytes(iter([1, 0]), 'little'))`
returns 1.
2020-01-05 16:02:10 +01:00
hauntsaninja
b7530cc79e
Add __init__ for subclasses of MappingView in python2 ( #3570 )
...
Resolves #3549 for python2
2020-01-05 15:11:38 +01:00
Faidon Liambotis
d87a4ffe0b
socketserver.BaseRequestHandler: add missing hint ( #3524 )
...
Add hint for __init__().
Fixes #3523 .
2020-01-03 08:48:49 -08:00
layday
e404e1592d
Preserve original type in total_ordering annotation ( #3552 )
...
See https://github.com/microsoft/pyright/issues/443
for reference.
2019-12-20 17:18:05 -08:00
Jan Verbeek
a705d59479
Add undocumented methods and make types more specific in 2/unittest ( #3550 )
2019-12-19 18:17:14 +01:00
hauntsaninja
6b321548c4
random: fix type for sample ( #3525 )
...
Fixes #3374
2019-12-04 13:07:24 -08:00
Jelle Zijlstra
d215f502c6
Improve warnings stubs ( #3501 )
...
* merge 2and3 for _warnings
* move warn and warn_explicit into _warnings
2019-12-03 14:33:37 +01:00
hauntsaninja
5fdd6ad1a5
builtins.print: make sep and end Optional ( #3468 ) ( #3511 )
...
The docs for Python 2 and Python 3 both explicitly mentions that None is a
valid value for sep and end.
https://docs.python.org/3/library/functions.html#print
2019-11-29 06:02:30 -08:00
robertschweizer
a9a4fd0d42
Add ImportError constructor arguments ( #3512 )
2019-11-29 06:01:30 -08:00
Benjamin Peterson
23c531df5a
Type socketserver's RequestHandlerClass as a callable. ( #3422 )
...
It's not uncommon to pass functions rather than actual types into the servers.
2019-11-25 20:18:17 -08:00
Ryan Hileman
693678b4c3
add no_type_check_decorator stub for #2884 ( #3460 )
2019-11-25 19:46:57 -08:00
Denis Laxalde
838e02334e
Fix type of imp.find_module() ( #3465 )
...
find_module is documented to return a tuple (file, pathname,
description) where "file" is open file object and "description" a tuple
(suffix, mode, type). The type of "file" was wrong ("str" instead of
"IO[Any]") as well as that of "suffix" ("IO[Any]" instead of "str");
probably those type definitions were swapped.
Fixes #3466 .
2019-11-20 10:29:05 +00:00
Michael Seifert
97ecd2b91f
Change the return type of __reduce__ and __reduce_ex__ to Union[str, Tuple[Any, ...]] ( #3453 )
...
This allows subclasses to return strings (which are allowed) from these
methods without having mypy throwing an error.
Closes #3452
2019-11-10 15:48:56 +01:00
Diego Elio Pettenò
99a6fb3108
Add the (deprecated) assertDictContainsSubset() to TestCase. ( #3437 )
...
Until this is removed from the standard library, it probably should stay in the typing.
Also update both 2 and 3 definitions to use Mapping[Any, Any], rather than Dict[Any, Any].
2019-11-04 08:10:45 -08:00
Diego Elio Pettenò
7e27bf6bde
Allow datetime() with a delta=timedelta() in assert(Not)AlmostEqual(s). ( #3426 )
...
While the documentation does not seem to make this particularly
obvious, it is allowed.
2019-11-02 22:35:09 -07:00
Rune Tynan
b112c20dad
Copyreg stubs ( #3387 )
2019-10-29 19:52:05 -07:00
Sebastian Rittau
87d7dd3d95
Fix annotations with literal values ( #3411 )
2019-10-28 06:59:28 -07:00
Alexander Schlarb
124111534a
Add the memoryview.release method ( #3405 )
2019-10-25 14:29:44 +02:00
Vasily Zakharov
4f13e710c3
Added stub for urllib.proxy_bypass() ( #3396 )
2019-10-22 19:10:50 +02:00
Sebastian Rittau
ec7960a8cb
Convert namedtuples to class syntax ( #3321 )
2019-10-20 10:37:33 +02:00
Rebecca Chen
ffd73b3e8e
Add shlex.shlex.next in Python 2. ( #3389 )
...
shlex.shlex should match the Iterator protocol, for which it needs both
`__iter__` and `__next__` (`next` in Python 2) defined.
2019-10-18 23:13:38 +02:00
Eric N. Vander Weele
966f8d24e6
Revert __import__ function annotation to return type back to Any ( #3383 )
...
From python/mypy#7582 .
This partially reverts back the change in
0ee7c3c38b to have `__import__` return
`Any` instead of `ModuleType`.
2019-10-18 00:10:41 +02:00
Sebastian Rittau
b969ead0ce
Reorder memoryview.__setitem__ overloads ( #3365 )
...
Necessary for python/mypy#7717
2019-10-15 14:14:48 +02:00
Sebastian Rittau
950f391704
Remove unnecessary __all__ annotations ( #3357 )
2019-10-13 16:22:03 -07:00
Sebastian Rittau
de26a3d109
Remove raise statements from function bodies ( #3355 )
...
While it may eventually be useful to mark the exceptions that can be
raised from a function or method, the semantics are currently undefined
and unclear.
2019-10-13 21:51:43 +02:00
Utkarsh Gupta
91b72d49c7
typing.pyi: Remove verbose and rename from NamedTuple ( #3352 )
...
Closes #3235
2019-10-12 21:27:50 +02:00
Florian Bruhin
9b0922166a
Allow callables in _SourceObjectType (Python 2) ( #3338 )
...
This is important because mypy doesn't generally think functions are compatible with `FunctionType`, so `inspect.getsource` on arbitrary functions is rejected by the current annotations.
2019-10-10 20:51:56 -07:00
Sebastian Rittau
8a7d61741d
Python3.8 additions and changes ( #3337 )
...
* Add as_integer_ratio() to a few types
* Add dirs_exist_ok to copytree()
* int, float, complex accept __index__ args
Also fix complex.__init__ argument names
* Add __reversed__ to dict et al.
* Python 3.8 date(time) arithmetic fixes
* Add CodeType.replace()
2019-10-10 20:51:27 -07:00
Russ Allbery
f0ccb325aa
Mark some urllib.parse return fields optional ( #3332 )
...
Per the urllib.parse documentation, username, password, hostname,
and port will be set to None if not set in the parsed URL. The
same is true for urlparse in Python 2 according to its documentation.
2019-10-09 19:38:59 +02:00
Sebastian Rittau
07c8675ba5
Remove unused # type: ignore comments ( #3325 )
2019-10-09 10:27:18 -07:00
wouter bolsterlee
824e94a933
Make 2-arg iter() retrun type match passed callable's return type ( #3326 )
...
This is a continuation of #3291 , which was the initial fix for #3201 .
The 2-arg version of iter() turns a callable into an iterator. The
changes made in #3291 introduce an Any return type for both the
callable's return type and the iterator's type, while in reality the
return type of the function is always the same as the iterator's type.
2019-10-09 08:44:41 +02:00
Sebastian Rittau
256b3ce8ab
Remove a bunch of unused imports ( #3323 )
2019-10-08 07:59:32 -07:00
Rune Tynan
7710e925ca
Add data to UserList class, fix UserDict.data type ( #3316 )
2019-10-07 17:05:19 +02:00
sinancepel
cd418e9546
introduce __floor__ and __ceil__ for int in Python 3 ( #3306 )
2019-10-04 19:16:32 -07:00
Rebecca Chen
90aa27b54a
Fix the signature of IOBase._checkClosed(). ( #3305 )
...
* In Python 2, the optional `msg` argument was missing.
* In Python 3, the method was missing altogether.
Reference:
https://github.com/python/cpython/blob/2.7/Lib/_pyio.py#L423
https://github.com/python/cpython/blob/3.6/Lib/_pyio.py#L443
2019-10-04 14:53:48 -07:00
Utkarsh Gupta
fa571fb224
builtins.pyi: Use two type vars ( #3291 )
...
Fixes : #3201
2019-10-04 00:15:41 +02:00
Sebastian Rittau
c32e1e2280
Enable --disallow-any-generics for stubs ( #3288 )
2019-10-01 05:31:34 -07:00
Eric Traut
468d13a205
Modified __add__ method in tuple class ( #3252 )
...
Modified __add__ method in tuple class to allow it to accept tuples with different generic parameter types. This allows, for example:
a = (1, )
b = a + (2.4, )
2019-09-30 12:42:40 +02:00
Guido van Rossum
b336182b69
Fix some errors with --disallow-any-generics ( #3276 )
...
See #3267 . Covers all of stdlib/2and3.
2019-09-29 09:15:27 -07:00
Árni Már Jónsson
e0cc8bdafb
inspect.Traceback/FrameInfo index/code_context attributes now Optional[] ( #3265 )
...
Resolves #3264
2019-09-26 17:13:00 +02:00
Rebecca Chen
3f8c2169d1
Define listdir in posix and import it in os. ( #3258 )
2019-09-23 23:41:05 +02:00
sinancepel
01b7002a89
Introduce explicit __str__ and __repr__ for Exceptions ( #3247 )
2019-09-23 18:25:49 +02:00
Rebecca Chen
9488b58fb3
Copy a better definition of abstractmethod from 3/abc to 2/abc. ( #3242 )
2019-09-18 11:04:53 +02:00
Benjamin Peterson
3fc8aec425
Allow passing str to Python 2's bytearray.extend. ( #3223 )
2019-09-04 23:24:58 +02:00
Sebastian Rittau
efb4af0108
Mark some types as non-hashable ( #3219 )
...
Based on @JelleZijlstra's PR #2221 .
Fixes #2148
2019-09-04 17:38:09 +02:00
Bouteillebleu
d5a918de7b
Add stubs for CGIHTTPServer ( #3196 )
...
This commit adds:
* Stubs for CGIHTTPServer in the Python 2 standard library, as requested in #1147 .
* Stubs for six.moves.CGIHTTPServer in Python 2, as requested in #22 .
2019-08-19 15:34:29 +02:00
Ran Benita
b2cd972b17
builtins: int.__pow__ can take a modulo argument ( #3192 )
...
See:
https://docs.python.org/3/reference/datamodel.html#object.__pow__
https://docs.python.org/3/library/functions.html#pow
2019-08-17 07:23:53 -07:00
Ran Benita
c7417e8b3f
builtins,numbers: harmonize float.__round__ and Real.__round__ ( #3193 )
...
See:
https://docs.python.org/3/reference/datamodel.html#object.__round__
https://docs.python.org/3/library/functions.html#round
2019-08-17 07:23:04 -07:00