Commit Graph

1693 Commits

Author SHA1 Message Date
Neil Pilgrim
ffe2bee7a7 Fix email.utils parseaddr and formataddr to accept Optional[str] (#1626) 2017-09-26 14:10:35 -07:00
Ben Leslie
b8f7ba8e8a Corrections to logging.StreamHandler stubs (#1624) (#1625)
- Missing attribute `StreamHandler.stream`
- Missing attribute `StreamHandler.terminator`
- terminator is only available in 3.3+
2017-09-23 18:36:51 -04:00
Luka Sterbic
1f867d8ab8 Fix int(Union[str, int]) (#1551) 2017-09-23 09:59:15 -04:00
Pieter-Jan Briers
d7533152f9 (3.6+) Adds re.RegexFlag and use it. (#1592)
* Make 3.6 functions take Union[int, RegexFlag] instead.
2017-09-23 08:58:31 -04:00
Øystein Olsen
6bfd43d6b6 Update utime stub (#1594)
times can be either a tuple of ints or floats
2017-09-23 08:57:38 -04:00
Bruce Merry
55dbb967ad Corrections to the asyncio exception stubs (#1623)
Fixes #1622:

- Missing attribute `LimitOverrunError.consumed`
- Missing attribute `IncompleteReadError.expected` and `.partial`
- `partial` argument to `IncompleteReadError` had incorrect type
- `expected` argument to `IncompleteReadError` missing `Optional`
2017-09-22 07:47:17 -07:00
aubanel
666f71fb56 Add a few methods to Element and ElementTree (#1585) 2017-09-22 07:11:15 -07:00
Jonathan Schoonhoven
dc46a435da allow all valid JSON in pynamodb JSONAttribute (#1604)
Currently, the type definition for `JSONAttribute` assumes the deserialized value will be a `dict`. However, a `list` is also a valid `JSONAttribute` (its [deserialize](495eae2867/pynamodb/attributes.py (L418)) method just calls `json.loads`.
2017-09-22 06:57:51 -07:00
Melvyn Sopacua
ebed7c2ecb Codeobject support (#1606) 2017-09-22 06:54:58 -07:00
Matthias Kramm
03ec4023ff Adjust ast imports to make pytype happy. (#1617)
Turns out that pytype is a bit more finicky about imports, and
differentiates between '*' imports for export, and imports
for use in the local pyi. This adjusts ast.pyi to make pytype
understand it again.
2017-09-22 06:27:27 -07:00
Amandine Lee
248f74d31b ConfigParser should use IO[str] for IO functions (#1621) 2017-09-22 06:25:17 -07:00
David Novakovic
b4e89a078c Second param of islice allows None. (#1603) 2017-09-20 14:55:16 -07:00
Ethan Smith
8ab207bcee Decrease Mypy concurrent process count (#1618)
Mypy has issues with running its test suite with many processes
concurrently. This should reduce travis test failures, if not completely
resolve failures. See issue https://github.com/python/mypy/issues/3543
2017-09-20 13:01:56 -07:00
rchen152
3d505d0c6b Re-export exception names in exceptions.pyi (#1611) 2017-09-19 15:19:40 -07:00
FichteFoll
cc3e753202 All loop kwargs in asyncio.streams are optional (#1615)
I verified this with the module code. All these loop arguments default
to `None` and are set with `events.get_event_loop()` if this is the
case.
2017-09-18 07:51:25 -07:00
rchen152
c009caf316 Make exceptions.pyi import its definitions from __builtin__.pyi (#1610)
* Make exceptions.pyi import its definitions from __builtin__.pyi

* Make ReferenceError a full class again.

* Restore blank line at EOF.
2017-09-15 14:52:54 -07:00
rchen152
0bf2958257 Correct a typo in stdlib/2/symbol.pyi (#1607) 2017-09-14 14:33:20 -07:00
Dominik Gabi
693509bff6 Change Union[float, None] to Optional in socket.pyi (#1602) 2017-09-13 13:23:54 -07:00
rchen152
1dfa570cae Fix the definition of nlargest() in stdlib/2/heapq.pyi (#1601)
* Fix nlargest() in stdlib/2/heapq.pyi

* Fix nlargest() syntax

* key can be None in heapq.nlargest
2017-09-12 08:27:41 -07:00
Mikołaj Biel
022da963b0 update shlex (python 3.6 updates) (#1599)
Update shlex to be compatible with changes from python 3.6: https://docs.python.org/3/library/shlex.html

Those changes should fix issues I've encountered:
```
main.py:10: error: No overload variant of "list" matches argument types [shlex.shlex]
main.py:10: error: Unexpected keyword argument "punctuation_chars" for "shlex"
/usr/local/lib/mypy/typeshed/stdlib/3/shlex.pyi:29: note: "shlex" defined here
```
caused by
```python
list(shlex(string, posix=True, punctuation_chars=True))
```
2017-09-11 12:30:48 -07:00
Elazar Gershuni
d4b21efbe8 Derive EnumMeta from ABCMeta (#1598)
Avoid inconsistent metaclass structure for enum mixins due to #1595 - e.g. mypy/#2824
2017-09-10 17:44:53 -07:00
John Reese
6865c24a4c Add support for multiprocessing.get_context().Process() (#1581) 2017-09-05 20:11:21 -07:00
Zack Hsi
a4285af4c2 Support PathLike argument to os.path.split (#1588) 2017-09-05 20:04:55 -07:00
rchen152
fd8be43044 Fix the return type of functools.update_wrapper() (#1589) 2017-09-05 20:03:51 -07:00
rchen152
8d5a233c6b Fix the definition of itertools.tee() (#1584) 2017-09-05 16:21:14 -07:00
Daniel Watkins
28d71e6f6f Flesh out smtplib types further (#1558)
This fixes all current partial signatures, as well as adding anything
that I happened to have to work out whilst fixing those partial
signatures.

The stubs remain incomplete.
2017-08-29 22:57:59 -07:00
Liran Nuna
c5f1e907fa More precisely typehint asyncio.gather up to 5 params (#1550) 2017-08-28 21:37:51 -07:00
Daniel Watkins
258b9fb821 Add IOBase to types fcntl will accept as files (#1556)
* Remove unused typing import from stdlib/3/fcntl.pyi

* Add IOBase to types fcntl will accept as files

Anything that implements a fileno() method is acceptable (per
https://github.com/python/cpython/blob/master/Objects/fileobject.c#L168-L173),
and IOBase fits the bill.

Fixes #1548.
2017-08-28 21:29:57 -07:00
Daniel Watkins
85a788dbca multiprocessing Pool (and context manager) fixes/improvements (#1562)
* Use typing.ContextManager for multiprocessing context managers

Prior to this commit, the types for __enter__ and __exit__ were not
fully defined; this addresses that.

* Move Pool class stub to multiprocessing.pool

This is where the class is actually defined in the stdlib.

* Ensure that __enter__ on Pool subclasses returns the subclass

This ensures that:

```py
class MyPool(Pool):
    def my_method(self): pass

with MyPool() as pool:
    pool.my_method()
```

type-checks correctly.

* Update the signature of BaseContext.Pool to match Pool.__init__

* Restore multiprocessing.Pool as a function

And also add comments to note that it should have an identical signature
to multiprocessing.context.BaseContext.Pool (because it is just that
method partially applied).
2017-08-28 21:19:08 -07:00
Jaen
87009939a5 ssl: Add missing constants & classes (#1569)
* ssl: Add missing PROTOCOL_TLS & OP_NO_TICKET constants

These were added in 3.5 and 3.6:
https://docs.python.org/3.5/library/ssl.html#ssl.PROTOCOL_TLS
https://docs.python.org/3.6/library/ssl.html#ssl.PROTOCOL_TLS_CLIENT

* ssl: Add missing SSLSession class

Reference:
5fe59f8e3a/Modules/_ssl.c (L4428)
2017-08-28 21:14:41 -07:00
Robert T. McGibbon
f1a13cea9c Add __init__ and __contains__ to argparse.Namespace (#1578) 2017-08-27 14:14:01 -07:00
Michael Lee
8afc1b7a08 Change subprocess constants to be type int (#1577)
This change modifies the PIPE, STDOUT, and DEVNULL constants in the
subprocess module to be of type 'int'.

Note that the Python 2 subprocess module was already typed this way;
this commit is just updating the Python 3 subprocess module in the same
way.
2017-08-26 17:07:25 -07:00
Alex Grönholm
023afbc098 Fixed the signature of six.raise_from() (#1563)
* Made the from_value argument optional in raise_from()

* Fixed six.raise_from() from_value and return type for both py2 and py3
2017-08-26 14:43:43 -07:00
Chris
875bfe4c2a Allow Any return value for callbacks in retrbinary etc (#1567)
Fixes #1258
2017-08-25 20:40:45 -07:00
Tim Crawford
341237339c requests: Add return type for __init__ methods (#1574) 2017-08-25 20:34:56 -07:00
Guido van Rossum
76685480e0 Misc fixes found by running mypy against Dropbox internal codebase "C". (#1575) 2017-08-25 20:34:13 -07:00
Daniel Watkins
1050b383a3 RawConfigParser dict_type argument should be a Type (#1572)
Fixes #1571.
2017-08-22 14:59:59 -07:00
Garrett
975c9a09ef Add range attributes (#1561) 2017-08-22 06:11:55 -07:00
Daniel Watkins
e8ece8ccce Replicate RawConfigParser.get* methods in SectionProxy (#1568)
These methods are partially applied (with the section that is being
proxied in SectionProxy) at runtime, so will always be present.

Fixes #1543.
2017-08-21 15:00:16 -07:00
Daniel Watkins
24a7bfb4bf Make configparser.RawConfigParser use SectionProxy where appropriate (#1527)
* Make configparser.RawConfigParser.__getitem__ return a SectionProxy

This reflects the code in the cpython tree and makes the following
(valid) code type-check correctly:

```
from configparser import ConfigParser

config = ConfigParser()
config.read_dict({'section': {'key': 'false'}})
assert config['section'].getboolean('key') is False
```

* RawConfigParser.items() returns SectionProxys not mappings

Because .items() uses __getitem__ to produce second item in each tuple.

* section argument to RawConfigParser.items is Optional

* Add comment explaining the status of RawConfigParser.items

TL;DR, we're hitting https://github.com/python/mypy/issues/3805 when
implemented correctly as an override, and
https://github.com/python/mypy/issues/1855 when we try to work around
that with a union.

* Correctly implement RawConfigParser.items overloading

* RawConfigParser.items(str) returns a List not an Iterable
2017-08-21 14:46:50 -07:00
Daniel Watkins
6f848e8ed8 Add definition for RawConfigParser._get_conv (#1542)
This allows subclasses that define get* methods to wrap _get_conv whilst
still typechecking correctly.
2017-08-21 14:09:42 -07:00
Jelle Zijlstra
4ea6c1cffb sys: clean up (#1545)
- More precise types for trace and profile functions
- Remove redundant comments
2017-08-21 13:54:55 -07:00
Jelle Zijlstra
c40b7afc14 accept PathLike in os.scandir (#1546) 2017-08-21 13:54:22 -07:00
Jelle Zijlstra
5c328f12e1 configparser: support PathLike (#1547)
RawConfigParser.read has code explicitly supporting PathLike objects.

Also removed an unused import and widened the accepted type from
Sequence to Iterable.
2017-08-21 13:42:35 -07:00
Jelle Zijlstra
e20a36ada2 add to CONTRIBUTING (#1560)
Ask contributors to better explain their changes and link to documentation and code. These things generally make pull requests easier to review.
2017-08-21 13:26:00 -07:00
Ivan Levkivskyi
42e2142f28 Add Protocol and runtime to typing_extensions (#1564)
* Add Protocol and runtime to typing_extensions

* Use private type variable

* Fix typo

* Bound type variable for runtime to only class objects

* Conform to version check specification
2017-08-21 13:22:48 -07:00
Artur Rodrigues
485c232409 Improve resource stubs for py3 (#1565) 2017-08-21 10:08:51 -07:00
Daniel Watkins
1c8f43b86c Add closefd keyword argument to Python 2's FileIO.__init__ (#1555)
Fixes #1553.
2017-08-17 20:47:08 +02:00
Svyatoslav Ilinskiy
4491e415f9 Make operations on set take AbstractSet[object] (#1533)
Previously they were `AbstractSet[Any]`
2017-08-11 17:17:47 -07:00
Ashwini Chaudhary
46a73bb2e8 Added private method _basic_auth_str to stub for requests (#1514) 2017-08-11 17:11:28 -07:00