Commit Graph

795 Commits

Author SHA1 Message Date
Sebastian Rittau
87ef6b8d53 Add stub for unittest.mock.patch.multiple() (#1686)
* Add stub for unittest.mock.patch.multiple()

* Use ... for default arguments in unittest.mock.patch() et al.

* Tighten type of create argument to patch() et al.
2017-10-26 00:57:56 -04:00
Matthew Wright
0b721b7af5 Update type of "throw" method of generators to reflect that it can return a value (#1672) 2017-10-25 16:54:18 -04:00
hashstat
c366a1be55 Merge v2 and v3 array stubs (#1670)
See #1608
2017-10-25 09:46:25 -07:00
Martin DeMello
817c270c32 Clean out the pytype blacklist (#1667) 2017-10-24 10:38:34 -07:00
Carl Meyer
9e76d44b09 Fix sys.setprofile annotation. (#1679)
`sys.setprofile(None)` is valid, and is in fact the only way to clear a profiler once set.
2017-10-23 15:26:58 -04:00
hashstat
6accffca28 popen() is function, not method, so remove self argument (#1671) 2017-10-12 12:16:14 -07:00
hashstat
d333474ed9 Update and add stubs for os module (#1645) 2017-10-09 21:02:10 -07:00
hashstat
29473745a8 Implement array.array as a MutableSequence (#1649)
It also improves the type checking of contained values. Some methods
were removed because they are implemented by a base class (i.e.,
*__iter__()*, *__str__()*, and *__contains__()*).  *__hash__()* was
removed because arrays are unhashable types.
2017-10-09 10:12:01 -07:00
Suren Nihalani
898299969c typeshed: declare that ordereddict's copy returns ordereddict (#1656) 2017-10-08 21:15:11 -07:00
Michael Lee
51829c1bc8 Update textwrap stubs (#1634)
This commit adds a few missing return types to the Python 3 textwrap
stubs and fleshes out the Python 2 textwrap stubs so they're on par with
the Python 3 version.

This change:

1.  Changes the order of the arguments in Python 2 and Python 3
    to match the order from the source code instead of the
    documentation.

2.  Adds other undocumented attributes besides whitespace_trans
    (for consistency).

3.  Moves the '*' argument in TextWrapper.__init__ for Python 3
    to match the source code.

4.  Made function stub formatting consistent with typeshed style
    conventions.
2017-10-08 21:12:19 -07:00
Semyon Proshev
bc91a22e4e Update datetime.timetuple and datetime.utctimetuple (Py3), and datetime.__init__ (Py2) (#1648)
* Update return type for datetime.timetuple and datetime.utctimetuple

* Fix microsecond parameter in datetime
2017-10-07 08:39:39 -07:00
hashstat
97b16a0b34 itertools.count() can take floats as well as ints (#1650) 2017-10-07 08:30:07 -07:00
Travis Parker
355f30cc70 Correct return type of sum() builtin (#1582)
`sum([])` always returns the integer 0.
2017-10-04 21:42:35 -07:00
Naman Bharadwaj
000041761e month, day parameters to datetime.datetime are required (#1633) 2017-10-04 21:38:09 -07:00
Jelle Zijlstra
78587dc895 Revert "make __class__ refer to the current object's class (#1549)" (#1632)
This reverts commit 1a164b630c.

Reverts python/typeshed#1549.

See Guido's comments in the original PR.
2017-09-29 11:37:54 -07:00
Jelle Zijlstra
1a164b630c make __class__ refer to the current object's class (#1549)
Fixes python/mypy#3061
2017-09-27 18:11:59 -07:00
Martin DeMello
d389ef3d85 Remove a few files from the pytype blacklist. (#1628)
Fixes the following issues:

* Literals rather than ... for default values
* None rather than ... for default value of typed variable
* Literals rather than ... # type for top level constants
* # Foo rather than # type: Foo
* return value of init not set to None
2017-09-27 07:57:13 -07:00
daid
d14272a14f Fix the typing for clock_settime (#1629)
clock_settime expects a float as parameter, and returns nothing.
2017-09-27 07:52:50 -07:00
Neil Pilgrim
ffe2bee7a7 Fix email.utils parseaddr and formataddr to accept Optional[str] (#1626) 2017-09-26 14:10:35 -07: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
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