Commit Graph

1943 Commits

Author SHA1 Message Date
Semyon Proshev
3e00a8f8e1 PEP 553 and PEP 564 (#1846)
* Add `breakpoint` to builtins (PEP 553)

* Add new `time` functions (PEP 564)
2018-01-31 16:51:25 -08:00
James M. Allen
33039f913e Adding py36 additions to datetime module (#1848) 2018-01-31 16:22:25 -08:00
Carl Meyer
1c3ec74d13 Remove incomplete thrift stubs that cause false positives. (#1827) 2018-01-26 15:26:14 -08:00
gossrock
79e0b94ef1 adding curses.ascii, curses.panel and curses.textpad modules (#1792)
* adding ascii, panal and textpad modules to the curses module.

* added curses/panel.pyi and curses/textpad.pyi to test/pytype_blacklist.txt
just like curses/__init__.pyi because they all import _curses. (This
may not be the right thing to do)
2018-01-26 14:39:55 -08:00
Garrett
372b541a07 Fix requests session hooks type (#1794) 2018-01-26 14:39:01 -08:00
Sebastian Rittau
6d7173b70b Add StringIO.name and BytesIO.name (#1802)
Also, change the type of StringIO.name (Python 3) from str to Any.

Neither StringIO nor BytesIO actually define a name field, but the
super-class IO[T] of both in typeshed does define a read-only property.
This means that sub-classes of StringIO and BytesIO adding this field
will not typecheck correctly.

Closes: #1790
2018-01-26 14:34:06 -08:00
Sebastian Rittau
a08d57833f Fix werkzeug environ type (#1831)
* Fix werkzeug environ type

PEP 3333 explicitly calls for environ to be a built-in dict. Using a
Mapping will not only prevent the dict from being modified (which is
explicitly allowed by PEP 3333), it will also cause interaction
problems when the environment is passed to other WSGI handlers.

Also change the value type from object to Any for convenience. By
definition, the values can be anything and can't be type checked.
Using object instead of Any forces us to explicitly cast the value
whenever we access it.

* Use Union[str, unicode] for Werkzeug environment keys

This matches the type in wsgiref.types.

* Use WSGIEnvironment from wsgiref.types

* Add '= ...' to environ attribute
2018-01-26 14:30:23 -08:00
rchen152
66e5863ead Change the return type of unittest.TestCase.fail() to NoReturn (#1843)
* Change the return type of unittest.TestCase.fail() to NoReturn

* Import mypy_extensions.NoReturn instead of typing.NoReturn
2018-01-26 14:28:37 -08:00
Yuri Khan
468d2fa629 _curses.tparm works on bytes, not str (#1828)
The documentation refers to the first argument as `str`
but careful reading reveals that its type,
and the function return type, is `bytes`.
2018-01-23 14:31:59 -08:00
Michael Lee
1e4c2a9031 Refine types for distutils.version (#1835)
Note: these type signatures were derived mainly by looking at the
docstrings inside distutils.version. For reference:

- py3 impl: https://github.com/python/cpython/blob/master/Lib/distutils/version.py
- py2 impl: https://github.com/python/cpython/blob/2.7/Lib/distutils/version.py
2018-01-23 14:29:22 -08:00
Yuri Khan
732726400f Add stub for stat.filemode (#1837)
Fixes #1836.
2018-01-23 14:27:01 -08:00
Martin DeMello
754789b031 modify pytype_test to run from within pytype too, and support python3 (#1817) 2018-01-22 12:18:58 -08:00
Ivan Levkivskyi
c2fa0a153a Minor improvements to simplejson stubs (#1832)
This fixes signatures of `load` and `loads` and cleans-up
`JSONDecodeError`.
2018-01-19 22:42:31 +00:00
David Zbarsky
7f3e01550b Add py2 stubs for multiprocessing.Queue (#1829)
This is basically the same API as in Python 3.
2018-01-18 00:06:15 +00:00
Sebastian Rittau
35edccce68 CONTRIBUTING: Use PEP 526 syntax in example (#1803)
* Add an example property, whitespace for grouping
* No default values from module-level constants
* Document that PEP 526 syntax is preferred
2018-01-17 10:28:45 -08:00
Elliott Beach
f207bc3cc3 add note about not squashing (#1830) 2018-01-16 16:26:48 -08:00
Matthias Kramm
72052d8338 Fix tests to work with newest version of pytype (#1824) 2018-01-12 12:28:19 -08:00
Michel Albert
5264fa6d5d Fix return-type of _BaseNetwork.supernet() (#1822)
The return type is currently defined as iterator, while it in fact returns a
network instance.
2018-01-11 08:24:11 -08:00
Nathan Henrie
9429ac070b Use Union[bytes, Text] instead of AnyStr (#1819) 2018-01-11 08:23:39 -08:00
rchen152
76c733dc5b Fix the return type of os.popen() (#1820) 2018-01-10 05:57:29 -08:00
Sebastian Rittau
7073bc0a49 Cleanup and merge datetime.pyi (#1805) 2018-01-09 22:06:31 +00:00
Jelle Zijlstra
2dd85c3658 move os.stat_result into posix stub (#1818)
This removes the circular dependency between the os and posix stub, which
is somehow triggering python/mypy#4442. We should ideally fix the mypy bug,
but since it's easy enough to fix the import cycle, we might as well do that
too.
2018-01-09 13:50:56 -08:00
Roy Williams
8175130688 Reexport DoesNotExist from pynamodb.models (#1809) 2018-01-10 05:00:39 +08:00
Elliott Beach
688f813457 fix subclassing ExitStack (#1810) 2018-01-08 06:02:30 -08:00
rchen152
db6e2a637b Fix some bugs in xml.etree.ElementTree.Element's container behavior. (#1816)
* Have Element inherit from MutableSequence, which is more precise than Sequence.
* Remove unnecessary inherited methods (e.g., __getitem__).
* Correct extend() to take an Iterable. (Sequence was too specific.)
* Alphabetize the typing imports, for sanity.
2018-01-04 19:04:46 -08:00
rchen152
29acda6431 Add itertools.imap signatures for more than two iterables. (#1815) 2018-01-04 19:03:41 -08:00
rchen152
af98a29823 Add __getslice__ to the Python 2 definition of mmap.mmap (#1812) 2018-01-04 16:16:00 -08:00
rchen152
592bdcc8a6 Fix the return type of textwrap.wrap (#1813) 2018-01-04 16:15:17 -08:00
rchen152
f6b60cb3ea A couple fixes to the io stubs. (#1811)
1. The 'name' argument to FileIO.init can be either a string or an integer: https://docs.python.org/2/library/io.html#io.FileIO
2. An mmap.mmap object can be used in most places that a bytearray can: https://docs.python.org/3.5/library/mmap.html
2018-01-04 16:14:38 -08:00
Jelle Zijlstra
fb2c7b34e2 Improve itsdangerous stubs (#1733) 2018-01-02 12:50:22 -08:00
Daniel Bowtell
bb8b9bdaec codecs.iter(en|de)code fix return type (#1807)
codecs.iterencode and codecs.iterdecode should both return Generators rather than Iterators
2018-01-02 12:49:34 -08:00
Salvo 'LtWorf' Tomaselli
c8c4a8f208 Added filelist attribute to ZipFile (#1798) 2018-01-02 10:18:03 -08:00
Jelle Zijlstra
4ee508a032 make os.scandir work as a context manager (#1787)
Rework of #1583. Fixes #1573.

See documentation in https://docs.python.org/3/library/os.html#os.scandir.
2018-01-02 10:17:38 -08:00
Thomas Broadley
2a30532f8d docs: fix typo (#1799) 2017-12-23 20:33:51 +01:00
Jelle Zijlstra
6509eee80e add util.pyi to blacklist (#1800) 2017-12-23 11:23:49 -08:00
Jelle Zijlstra
0eb7083f0e move dateutil into 2and3 (#1743)
These stubs are identical since #1735.
2017-12-23 06:38:55 -08:00
Elazar Gershuni
b41c6dafee Make Enum Iterable (etc.) only structurally (#1755)
Can't express the precise type nominally - see mypy#3210 for details

* Make self generic in __contains__
2017-12-21 13:32:10 -08:00
Anthony Sottile
03044212d4 Add typings for bool __{r,}{and,or,xor}__ (#1795) 2017-12-20 21:04:55 -08:00
Sebastian Rittau
64ca731d0b jinja2: Add Template.environment (#1789)
From the docstring for Template: "Template objects created from the
constructor rather than an environment do have an `environment`
attribute that points to a temporary environment ..."
2017-12-17 10:04:53 -08:00
Semyon Proshev
4b6b484786 Add clear method to MutableSequence in Python 3 (#1765) 2017-12-15 19:37:43 -08:00
Alex Dehnert
8404a62231 requests: add more accurate stubs for certain fields of the Session object (#1504)
* requests: allow strings in Session.verify

Per the documentation[1] (and actual usage), the verify parameter can be a
string or a bool.

[1] http://docs.python-requests.org/en/master/user/advanced/#ssl-cert-verification

* requests: explicitly support AuthBase for Session.auth

According to the documentation, the auth parameter should be an AuthBase
subclass[1].  In practice, the actual requirement seems to just be a
Callable[[Request], Request], and AuthBase implements that with the __call__
method. However, mypy isn't currently smart enough to infer that __call__
implies Callable[2]. In the interim (and perhaps also to add clearer errors),
explicitly support AuthBase.

Additionally, this adds typing of AuthBase.__call__, to match the
Callable[[Request], Request] declaration used elsewhere.

[1] http://docs.python-requests.org/en/master/user/advanced/#custom-authentication
[2] https://github.com/python/mypy/issues/797
2017-12-14 21:05:28 -08:00
Ashwini Chaudhary
c5439668fe Added stub for sre_compile(2and3) (#1493) 2017-12-14 20:52:54 -08:00
gossrock
cb1d150092 Improvements to stdlib/3/_curses.pyi - take 3 (#1772)
* Added missing annotation for start_color() and wrapper() functions

* 1) Changed Optional types to be optional arguments (checked documentation and manual experiments to make sure I was doing it right)

2) Modified format to match CONTRIBUTING.md conventions

3) corrected a few missing return types or other mistaken type
annotations
2017-12-14 20:38:39 -08:00
Roy Williams
1dccd1fdc4 Allow requests.post to accept Dict[str, str] for data. (#1777)
* Allow `requests.post` to accept `Dict[str, str]` for `data`.

For example:

```python
import requests
requests.post('https://www.foo.bar', data={'hello': 'world'})
```

Failes to type check in Python 2 even though it's fine.

* Explode str/Text combinations

* Fix lint

* Simplify iterable parameter for data
2017-12-14 20:36:21 -08:00
Sebastian Rittau
398401baee werkzeug: Mark BaseRequest.data as property (#1785) 2017-12-14 20:35:29 -08:00
Alan Du
7c4765357a Make requests.Response.iter_content allow None (#1784)
* Make requests.Response.iter_content allow None

According to the docstring:
> chunk_size must be of type int or None

* Combine and alphabetize import statement
2017-12-13 14:25:32 -08:00
Semyon Proshev
a1e85be4c9 Add __int__ to uuid.UUID (#1783) 2017-12-13 08:20:47 -08:00
Neil Conway
46125886c0 argparse: Add annotations for instance variables. (#1763) 2017-12-12 15:10:31 -08:00
Roy Williams
10a76c1fdd Export Connection and TableConnection from pynamodb.connection (#1779)
It looks like in recent versions of mypy this stopped being exported.
2017-12-07 14:35:13 -08:00
Elazar Gershuni
97fb265a4c Avoid over-constraining selftype of EnumMeta (#1770)
This is needed for python/mypy#4311, and is sound.
2017-12-04 11:21:57 -08:00