Commit Graph
600 Commits
Author SHA1 Message Date
Jelle ZijlstraandGitHub 43e93f803f use _typeshed's Path aliases (#4214) 2020-06-10 20:57:09 -07:00
Jelle ZijlstraandGitHub ea577cec1f move OpenTextMode and friends to _typeshed (#4213) 2020-06-10 15:36:21 +02:00
Mikhail GolubevandGitHub 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
Luciano RamalhoandGitHub bb9e1a649c using type var to work around List invariance (#4192) 2020-06-06 18:32:15 -07:00
DakkaronandGitHub 3438cb92e1 pipes.quote takes AnyStr (#4173) 2020-06-04 12:37:57 +02:00
Sebastian RittauandGitHub a913af9523 flake8: Enable F811 (#4158) 2020-06-02 14:08:54 -07:00
Jelle ZijlstraandGitHub 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
Rune TynanandGitHub d863210335 Improve TypeVar stub (#4150) 2020-05-30 20:27:59 -07:00
Markus PielmeierandGitHub b7d9a4a584 Add support for __pow__ with pow() builtin (#4109) 2020-05-30 15:38:19 -07:00
ShantanuGitHubhauntsaninja <>
de2c2947fe windows: fix splitunc param name (#4143)
Co-authored-by: hauntsaninja <>
2020-05-29 20:37:19 -04:00
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 ZijlstraandGitHub 0cffa59e57 use a Protocol for str.format_map() (#4122)
Fixes #3824
2020-05-28 13:27:57 +02:00
Rune TynanandGitHub 712f6d3709 Fix winreg pos-only args and parameter names (#4117)
* Fix winreg pos-only args and parameter names

* Fix consistency check
2020-05-27 20:22:32 -07:00
Brad SolomonandGitHub 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
ShantanuandGitHub fd203e663e py39: add PEP 616 methods (#4090) 2020-05-27 19:24:25 -07:00
Rune TynanandGitHub fcdfacf944 Fix stubtest failures for socketserver on windows (#4103) 2020-05-27 19:34:35 +02:00
Rune TynanandGitHub e49c156d92 Add winreg stubs (#3794) 2020-05-27 17:15:08 +02:00
Rune TynanandGitHub 5e80ca9e44 Fix stubtest failures for path files on windows (#4096) 2020-05-27 09:39:26 +02:00
Nguyễn Gia PhongandGitHub 0aa9060e66 Remove context manager hints in multiprocessing.pool in Python 2 (#4060) 2020-05-23 22:11:19 +02:00
Rebecca ChenandGitHub 037377f502 Mark the arguments to os.killpg as positional-only in Python 2. (#4033)
This was already done in Python 3. In Python 2 as well, this method does
not take keyword arguments.
2020-05-17 18:06:35 -07:00
Selim BelhaouaneandGitHub 3ac1f86499 Change return annotation of Popen.poll to Optional[int] (#3986)
Fixes #3984
2020-05-13 10:18:25 -07:00
Ivan LevkivskyiandGitHub 8c7f489d1b Organize special forms in typing (#3966)
This is an accompanying PR for https://github.com/python/mypy/pull/8779, see https://github.com/python/mypy/pull/8779#issuecomment-624001349

I also noticed that Python 2 and Python 3 versions are a bit out of sync, so I also put them back in sync.
2020-05-05 13:55:31 +01:00
ShantanuandGitHub e857ad6ba9 zip: add some overloads for heterogeneous tuples (#3830)
Technically this is a lie, since we return a heterogeneous iterator, not
a tuple. But since we don't have a way of typing heterogeneous
iterators, this is the best we can do.

Fixes https://github.com/python/mypy/issues/8454
2020-05-03 21:02:26 -07:00
Philipp HahnandGitHub 84147ec9cb sockeserver: Add undocumented internals (#3924)
the `rfile` and `wfile` members are already implemented by
StreamRequestHandler. In addition to them several (undocumented)
class and instance variables exist according to
<https://github.com/python/cpython/blob/master/Lib/socketserver.py#L742>:
- `rbufsize`
- `wbufsize`
- `timeout`
- `disable_nagle_algorithm`
- `packet` and `socket` for datagrams

The already exist with Python 2.7
<https://github.com/python/cpython/blob/2.7/Lib/SocketServer.py#L677>

```mermaid
classDiagram
BaseRequestHandler <|-- DatagramRequestHandler
BaseRequestHandler <|-- StreamRequestHandler
StreamRequestHandler <|-- BaseHTTPRequestHandler
```
2020-04-14 13:22:40 -07:00
Peter PentchevandGitHub 0d7665d7b8 SyntaxError's filename and lineno may be undefined. (#3918)
The Python source (Objects/exceptions.c) explicitly checks for null
pointers before using the filename and lineno members. Some libraries,
e.g. pkg_resources, set filename and lineno to undefined values if
indeed none are appropriate.
2020-04-08 20:50:49 +02:00
Debjyoti BiswasandGitHub f4a646d43c Add PathLike to genericpath.exists and re-export (#3897)
Closes#3492
2020-04-02 09:51:59 +02:00
Peter PentchevandGitHub 92741c74ff subprocess.Popen(cwd) is optional in Python 2.x, too. (#3857) 2020-03-17 14:39:05 +01:00
Jan VerbeekandGitHub 6f159d9fc6 Make Python 2's inspect more tolerant of unicode (#3847) 2020-03-13 20:48:42 -07:00
ShantanuandGitHub 6b4fd79808 builtins: add mod to various power functions (#3816) 2020-03-06 11:07:05 +01:00
Jelle ZijlstraandGitHub 6a4044fd9b Make frozenset covariant (#3808)
The convariance was lost in #1057
2020-03-04 19:24:03 -08:00
Ivan LevkivskyiandGitHub 8b28b49c61 Mark some obviously incomplete stubs as incomplete (#3807) 2020-03-04 17:02:14 +00:00
Ran BenitaandGitHub 36c6f94de4 stdlib/2and3/builtins: change dict.fromkeys to classmethod (#3798)
The referenced issue in mypy is fixed.
2020-03-01 23:25:52 -08:00
ShantanuandGitHub a19caac361 os.path: fix arg names (#3748) 2020-02-21 11:55:21 +01:00
ShantanuandGitHub 87791e4e15 re: various fixes (#3746)
* re: mark positional-only args

* re: fix escape arg name

* re: update whitelist
2020-02-21 11:55:11 +01:00
MarkandGitHub 39008d51c1 Make itertools.cycle a type (#3732) 2020-02-09 13:34:41 +01:00
Rune TynanandGitHub e8f85d9479 Fix missing types in builtins/__builtin__ (#3705)
* Fix missing type in builtins/__builtin__

* Add return type to memoryview cast
2020-02-02 22:13:48 -08:00
Wolf HonoreandGitHub 211aec7b22 socketserver: Add missing attributes and methods for ForkingMixIn and ThreadingMixin (#3672)
* Add missing attributes and methods for ForkingMixIn and ThreadingMixin

* Copy socketserver.py to SocketServer.py

* Fix type of timeout
2020-02-01 09:30:43 -08:00
ShantanuandGitHub 70f0dc1491 builtins: fix bytearray.fromhex (#3691)
bytearray.fromhex is a classmethod, not a staticmethod
Mark positional-only args in the other fromhex's
2020-01-30 18:58:36 -08:00
ShantanuandGitHub 9798c243c9 builtins: start can be passed by keyword to sum in 3.8 (#3692) 2020-01-30 18:56:50 -08:00
Jan VerbeekandGitHub 95cafc0b7c sys: Correct types of sys.displayhook, sys.excepthook and variants (#3673)
displayhook should accept any object, not just integers.

displayhook and excepthook may be assigned to, so they should be
Callable values rather than function definitions. That way it's fine
to assign a function with different argument names. Their dunder
variants are supposed to be constant.
2020-01-29 11:25:35 +01:00
Ilaï DeutelandJelle Zijlstra e7ddb21ae6 range.index() takes exactly one argument (#3668) 2020-01-27 20:19:12 -08:00
ShantanuandSebastian Rittau ed95668638 builtins.pow: improve annotation (#3647) 2020-01-24 09:20:46 +01:00
ShantanuandSebastian Rittau 32563e9e1d builtins: mark positional-only args as such (#3648) 2020-01-23 15:35:45 +01:00
Rebecca ChenandSebastian Rittau 3b3fc6a57f Make os.statvfs_result inherit from typing.NamedTuple. (#3603) 2020-01-10 22:42:29 +01:00
ShantanuandJelle Zijlstra 61600d6877 memoryview: add cast, obj attribute (#3598)
Fixes #3594
2020-01-09 15:57:17 -08:00
Rebecca ChenandJelle Zijlstra e0151e724a Make unittest.FunctionTestCase inherit from TestCase in Python 2. (#3597)
This makes the pyi file match the implementation:
https://github.com/python/cpython/blob/249706c1fbce04125d81bd9993e6c010ae30f8e4/Lib/unittest/case.py#L1019.

I also removed a now-redundant `run` method from FunctionTestCase
because the mypy test complained about it having a different signature
from TestCase.run().

Context:
https://github.com/python/typeshed/pull/3550#issuecomment-572702513.
2020-01-09 13:04:08 -08:00
Daniel FarleyandRebecca Chen 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
hauntsaninjaandJelle Zijlstra 1efc1baaf7 stdtypes: update for py38 (#3580) 2020-01-06 20:57:34 -08:00
JasonandSebastian Rittau 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
hauntsaninjaandSebastian Rittau b7530cc79e Add __init__ for subclasses of MappingView in python2 (#3570)
Resolves #3549 for python2
2020-01-05 15:11:38 +01:00