Commit Graph

776 Commits

Author SHA1 Message Date
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
Melvyn Sopacua
ebed7c2ecb Codeobject support (#1606) 2017-09-22 06:54:58 -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
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
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
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
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
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
Artur Rodrigues
485c232409 Improve resource stubs for py3 (#1565) 2017-08-21 10:08:51 -07: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
Evan Krall
9db63fee91 Make IOBase.__enter__ return the same type as self. Fixes #1540. (#1541) 2017-08-11 16:06:07 -07:00
Alex Ellis
10a3e43a19 Queue stubs: Make LIFOQueue and PriorityQueue generic (#1538) 2017-08-10 20:15:43 -07:00
Adam Dangoor
7fe417ca58 In Python 3.4 and above, os.makedirs and os.removedirs use the kwarg "name" rather than "path" (#1536) 2017-08-08 18:42:29 -07:00
Jelle Zijlstra
d60f26c448 add object.__dir__ in Python 3 (#1532)
In Python 3 (but not Python 2), `object().__dir__()` works and returns a list of strings.

This is relevant when implementing a custom `__dir__` that invokes `super().__dir__()`.
2017-08-07 19:29:13 -07:00
Brian C. Lane
19275ea38a Make multiprocessing.Queue a subclass of queue.Queue (#1525)
Also change multiprocessing.Queue's put and get timeout arguments to
allow None.

This fixes a problem with logging.handlers.QueueHandler and
QueueListener not accepting a multiprocessing.Queue as the queue
argument.

Declaring the Queue now needs to note what it will be used for. eg.
q = multiprocessing.Queue()    # type: multiprocessing.Queue[List[Any]]
2017-08-07 19:25:53 -07:00
Svyatoslav Ilinskiy
8ac0694056 Make functions any and all accept Iterable[object] (#1531)
Previously, they were accepting `Iterable`, which expanded to `Iterable[Any]`.
2017-08-07 17:13:43 -06:00
Svyatoslav Ilinskiy
3f9fafbbb7 Re-export code from _ast into ast. (#1515)
After mypy [started hiding](https://github.com/python/mypy/pull/3706) imported names in stubs unless `from ... import ...` is used, we found an error with stubs of ast module. 

It looks like ast module should re-export everything in `_ast` and according to PEP 484, it can do that by doing `from _ast import *`, so this is what this PR does.
2017-08-03 15:57:20 -07:00
Svyatoslav Ilinskiy
aa68403230 Make BaseException's init accept object instead of Any (#1518) 2017-08-03 12:57:59 -07:00
Ashwini Chaudhary
baea852b62 Added stub for sre_parse and sre_constants(py3) (#1502)
* Added stub for sre_parse(py3)

* Fixed return type of SubPattern.__getitem__

* Typo

* Fix for issue related to error class

* Added stub for sre_constants(py3)

* Added missing import
2017-08-01 14:38:49 -07:00
blokeley
c5479b11bb Add private methods stubs to queue.Queue (#1507)
It is a common pattern to subclass queue.Queue and override the private methods _init, _get, _put and _qsize so they should have stubs.
2017-08-01 14:37:51 -07:00
Jelle Zijlstra
2d97894fa9 collections: make UserDict, UserList, and UserString concrete (#1477)
* collections: make UserDict, UserList, and UserString concrete

* add version checks

573b44c18f

* remove redundant methods
2017-07-26 16:34:43 -07:00
Semyon Proshev
72fbc459a7 Add __init__ to types.MethodType (#1499) 2017-07-26 08:38:27 -07:00
Thomas Grainger
15c8474e35 fix email.mime (#1482)
* add missing python 2 email.mime.application stub

* restore missing python 3 mime package

* Delete __init__.py
2017-07-26 08:29:30 -07:00
Michael Lee
6d3024fb19 Add NoReturn type to typing stubs (#1496) 2017-07-20 21:24:34 -07:00
toejough
f6b013ba52 ignore type for mock.pyi inheritance from Any (#1492)
It is currently required to shut up mypy when run with `--strict`
or `--disallow-subclassing-any`. The `Any` base class is currently
the only way to allow passing an instance of `Mock` to functions
expecting other classes (as is Mock's purpose).
2017-07-19 11:33:59 -07:00
Jelle Zijlstra
be7490322b Counter: fix return value of most_common() (#1491)
https://docs.python.org/3/library/collections.html#collections.Counter.most_common
https://docs.python.org/2/library/collections.html#collections.Counter.most_common
2017-07-19 20:29:32 +03:00
Jelle Zijlstra
00ddb1c84a encodings: IncrementalEncoder and Decoder concrete (#1490)
These stubs are identical in Python 2 and 3, but I believe they
should not be merged, because there are numerous other modules
in the encodings package, and some only exist in some Python
versions. I don't think we can support that in the 2and3
directory.
2017-07-19 20:28:43 +03:00
Jelle Zijlstra
32d9c8cb8f make io.IncrementalNewlineDecoder concrete (#1489)
Part of #1476
2017-07-19 20:28:25 +03:00
Jelle Zijlstra
ac651d2f8c Fix a few TODOs (#1487)
* fix some easy TODOs

* fix io
2017-07-19 20:27:50 +03:00
Jelle Zijlstra
1515ed9f88 fix some abstract classes in third_party/ (#1486) 2017-07-19 20:27:22 +03:00
eujing
be31439168 Added missing Process fields; More accurate Optional parameters (#1483) 2017-07-18 19:17:23 -07:00
Ivan Levkivskyi
d75ea88da5 Use 'as name' patter to re-export names from stubs (PEP 484) (#1484) 2017-07-14 21:31:53 -07:00
Luka Sterbic
dd7ff91519 Support mp.Value.value (#1480) 2017-07-12 15:00:14 +02:00
Ashwini Chaudhary
47b3979a83 Added stub for Python 3's _threading_local (#1462) 2017-07-10 21:20:02 -07:00
Jelle Zijlstra
16aa0651ae Revert "Add __new__ to str and int stubs in both Pythons. (#1352)" (#1466)
This reverts commit fed4e03e53.
2017-07-06 14:21:54 -07:00