Commit Graph
1811 Commits
Author SHA1 Message Date
Jelle ZijlstraandMatthias Kramm 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 BroadleyandIvan Levkivskyi 2a30532f8d docs: fix typo (#1799) 2017-12-23 20:33:51 +01:00
Jelle ZijlstraandGitHub 6509eee80e add util.pyi to blacklist (#1800) 2017-12-23 11:23:49 -08:00
Jelle ZijlstraandMatthias Kramm 0eb7083f0e move dateutil into 2and3 (#1743)
These stubs are identical since #1735.
2017-12-23 06:38:55 -08:00
Elazar GershuniandJelle Zijlstra 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 SottileandJelle Zijlstra 03044212d4 Add typings for bool __{r,}{and,or,xor}__ (#1795) 2017-12-20 21:04:55 -08:00
Sebastian RittauandJelle Zijlstra 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 ProshevandJelle Zijlstra 4b6b484786 Add clear method to MutableSequence in Python 3 (#1765) 2017-12-15 19:37:43 -08:00
Alex DehnertandJelle Zijlstra 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 ChaudharyandJelle Zijlstra c5439668fe Added stub for sre_compile(2and3) (#1493) 2017-12-14 20:52:54 -08:00
gossrockandJelle Zijlstra 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 WilliamsandJelle Zijlstra 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 RittauandJelle Zijlstra 398401baee werkzeug: Mark BaseRequest.data as property (#1785) 2017-12-14 20:35:29 -08:00
Alan DuandJelle Zijlstra 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 ProshevandJelle Zijlstra a1e85be4c9 Add __int__ to uuid.UUID (#1783) 2017-12-13 08:20:47 -08:00
Neil ConwayandJelle Zijlstra 46125886c0 argparse: Add annotations for instance variables. (#1763) 2017-12-12 15:10:31 -08:00
Roy WilliamsandJelle Zijlstra 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 GershuniandGuido van Rossum 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
Neil PilgrimandJelle Zijlstra fc10a94db1 Distutils improvements to cmd.pyi and log.pyi (#1748)
* Add more functions to distutils.cmd.Command.

* Add detail to distutils.log, previously an empty file.
2017-11-27 15:47:04 -05:00
Tim AbbottandJelle Zijlstra c1971fb443 imaplib: Fix annotation for search. (#1762)
* imaplib: Fix annotation for search.

https://docs.python.org/3/library/imaplib.html#imaplib.IMAP4.search
shows that IMAP4.search takes a number of str args, not a number of
List[str] args (I can see how one would be confused, though, because
of the *criteria).

* imaplib: Fix annotation for store.

While it's called "flag_list",
https://docs.python.org/3/library/imaplib.html#imaplib.IMAP4.store
clearly shows it's expecting a string with a list of flags in it, not
a Python list.
2017-11-25 13:23:57 -08:00
Semyon ProshevandJelle Zijlstra b0d9752a1c Make func in builtin map optional in Python 2 (#1751)
* Make `func` in builtin `map` optional in Python 2

* Add `map` overloads with `None` `func` in Python 2
2017-11-22 07:57:07 -08:00
Sebastian RittauandJelle Zijlstra 622e744f3e Extract WSGIEnvironment and change value type to Any (#1745)
* Extract WSGIEnvironment in wsgiref.types

* Change value type of WSGIEnvironment to Any

Per PEP 3333, a WSGI environment can contain anything, not just strings.
2017-11-21 17:00:49 -08:00
Masayuki YamamotoandJelle Zijlstra 39eefa544c Fix parameters of socketserver.BaseServer.finish_request() (#1754)
See also: python/cpython#4445
2017-11-21 16:42:05 -08:00
rchen152andJelle Zijlstra 8753fc78df Add setUpClass and tearDownClass to unittest.TestCase in Python 2 stub (#1760) 2017-11-21 16:39:11 -08:00
gossrockandJelle Zijlstra 15983ffc51 Add LINE and COL definitions to /stdlib/3/curses/__init__.py (#1757)
Fixes #1596
2017-11-20 13:44:20 -08:00
Ivan LevkivskyiandGuido van Rossum ec2cb8e44f Convert selected ABCs to Protocols (#1220) 2017-11-19 08:52:16 -08:00
Ben LeslieandGuido van Rossum 7806420105 Fix missing colon in StreamHandler.stream type annotation (#1753)
The missing colon in the variable type annotation means that the type of stream is currently incorrectly determined to be of type ellipsis, rather than IO[str].
2017-11-18 15:57:55 -08:00
Guido van RossumandJelle Zijlstra 821c765991 Several packages always auto-import certain submodules on import (#1752)
* Importing yaml implies yaml.resolver

* Importing six implies six.moves

* Importing requests implies requests.packages
2017-11-17 15:15:40 -08:00
Ethan SmithandJelle Zijlstra 7737e519a3 Add __dict__ to object in Python 2 (#1746)
Use str as key type for __dict__
2017-11-16 08:44:48 -08:00
Semyon ProshevandJelle Zijlstra 7c11ae03de Add __qualname__ to functions and methods (#1750) 2017-11-16 08:37:36 -08:00
Semyon ProshevandJelle Zijlstra 3029357ad7 Add unicode.__rmul__ (#1749) 2017-11-16 08:31:55 -08:00
Sebastian SteenbuckandMatthias Kramm 8b56c1e59a Add all the files which pytype fails on during import. (#1720)
All of these files can not be used with pytype at HEAD. They fail during import with various error messages. Make the test script actually load the files and all dependencies of it, instead of just verifying that it can be parsed.

This list was generated by running pytype with more options.
1: typeshed-location was pointed to the current typeshed instead of the one shipped with pytype.
2: --module-name=<foo> was provided as a parameter. Without this parameter wildcard imports "from _ast import *" misbehave.

Files with a "# parse only" comment will only be parsed and not loaded.
2017-11-15 06:29:07 -08:00
Jelle ZijlstraandMatthias Kramm 533a05be45 Fix some of the last default values that are not ... (#1731)
* still one left in atomicwrites that I need to investigate further
* fix atomicwrites
2017-11-13 07:08:30 -08:00
Jelle ZijlstraandMatthias Kramm 69bffd154a Fix default values in click stubs to ... (#1734) 2017-11-13 07:07:20 -08:00
Jelle ZijlstraandMatthias Kramm 8e75701eda make Python 2 and 3 dateutil stubs identical (#1735)
So that they can be merged into 2and3. This PR also adds a few missing
elements to parser.pyi and corrects some mistakes in the Python 3 stub.

Refer to https://github.com/dateutil/dateutil/tree/master/dateutil
2017-11-13 07:06:34 -08:00
Jelle ZijlstraandMatthias Kramm 84d0cbf776 move thrift to 2and3 (#1736)
thrift supports Python 3 as of version 0.10.0. These stubs are pure stubgen and
might not be much good, but they belong in 2and3.
2017-11-13 07:05:57 -08:00
Jelle ZijlstraandMatthias Kramm bcfd3bf554 Fill out croniter stubs and move to 2and3 (#1737)
* fill out croniter stub
* move to 2and3
2017-11-13 07:05:38 -08:00
Patrick ValsecchiandMatthias Kramm d62743d788 Make traceback.FrameSummary Iterable (#1741)
To make this code valid:
```python
import traceback
for filename, lineno, name, line in traceback.extract_stack(stack):
    pass
```
2017-11-13 07:05:16 -08:00
Jelle ZijlstraandMatthias Kramm 83ca997140 Change more defaults to ... (#1729)
* codemod ': Any = None' ': Any = ...'
* codemod ': (Union|Optional)([^=]+)\s+=\s+-?\d+' ': \1\2 = ...'
* codemod ': (Union|Optional)([^=]+)\s*=\s*-?(None|False|True)' ': \1\2 = ...'
* codemod ': (int|float|bool)\s*=\s*-?\d+' ': \1 = ...'
* codemod ': (bool)\s*=\s*(False|True)' ': \1 = ...'
* codemod ': Any\s*=\s*(False|True|None)' ': Any = ...'
2017-11-13 06:56:24 -08:00
Jelle ZijlstraandMatthias Kramm 0080017d02 fill out bz2 stub (#1728)
- add a default value to ...
- add some missing version checks
- add some missing arguments
2017-11-13 06:55:43 -08:00
Nathan HenrieandJelle Zijlstra 87fca814b1 addr should be Tuple[str, int], not str (#1740)
I think `addr` here should also be  `Tuple[str, int]`, the same change made to `sendto` in [this pr merged a few months ago](https://github.com/python/typeshed/commit/0e26c1f9361bd2d57b9f361c4fbd8185243afb21#diff-d21efb8da2d73c6c7c769270b387cd47).
2017-11-12 23:14:16 -08:00
Alex WillmerandJelle Zijlstra 55f15427bd Refine stdlib commands module (add mkarg(), mk2arg(), correct get*()) (#1739) 2017-11-12 22:44:51 -08:00
FichteFollandJelle Zijlstra a44de46a00 use_builtin_types is optional for plistlib.load (#1738) 2017-11-11 16:54:11 -08:00
Jelle ZijlstraandMatthias Kramm 97be335160 don't import enum in Python 2 (#1724)
* don't import enum in Python 2

Fixes a pytype issue from #1720.

* move enums together
2017-11-10 10:23:22 -08:00
Jelle ZijlstraandMatthias Kramm 9390a49600 complete multiprocessing.connection stub (#1716)
Adds additional public members based on https://github.com/python/cpython/blob/master/Lib/multiprocessing/connection.py#L10 and https://docs.python.org/3/library/multiprocessing.html#multiprocessing-listeners-clients.

I found some discrepancies in the docs while adding these stubs and filed python/cpython#4304 to address them.
2017-11-09 10:40:49 -08:00
Jelle ZijlstraandMatthias Kramm 324f1761f4 Change more defaults to ... (#1727) 2017-11-09 10:32:17 -08:00
Josh StaigerandJelle Zijlstra fd25e534ad Add default timeout for Condition.wait_for (#1726)
Fixes:

- Too few arguments for "wait_for" of "Condition"

when timeout is not specified.
2017-11-09 10:12:33 -08:00
Jelle ZijlstraandMatthias Kramm 54dd6ba27c Change numerous default values to ... (#1722)
This is the convention, and some default values (e.g. strings) apparently
break pytype.
2017-11-09 06:28:40 -08:00
Daniel AxtensandMatthias Kramm 66821993f6 Fix email header types (#1472)
Some email header operations can operate on or return a Header object as well as a string.
2017-11-09 06:03:11 -08:00
Kenny DoandMatthias Kramm 26ea6c0740 pkgutils.walk_packages takes optional list of str for path (#1725) 2017-11-09 05:57:29 -08:00