Commit Graph

838 Commits

Author SHA1 Message Date
Nick Gaya
3e85d6bb61 Add missing unittest.mock.patch attributes (#1882) 2018-02-16 09:13:33 -08:00
Marti Raudsepp
d288f443b9 Merge {IO,Environment,Windows}Error into OSError for Python 3.3+ (#1852)
Starting with Python 3.3, IOError, EnvironmentError and WindowsError are
aliases for OSError, which has all the attributes.

Reference:
* https://docs.python.org/3/library/exceptions.html#OSError
* https://www.python.org/dev/peps/pep-3151/

* OSError: Drop Python <3.3 compatibility
* Use Any instead of Union for filename/filename2 type, per GvR comment
See: https://github.com/python/mypy/pull/4541
2018-02-14 16:33:56 +00:00
rchen152
8d46ada49d Add undocumented but occasionally used attributes to inspect.pyi. (#1864)
* Add attributes not in docs to 2/inspect.pyi.
* Add attributes not in docs to 3/inspect.pyi.
* Change list to List[Any] in 2/inspect.pyi
2018-02-14 16:20:55 +00:00
Salvo 'LtWorf' Tomaselli
b33c7d1a84 Add missing private field to NamedTuple (#1866)
It is very useful for doing introspection.
2018-02-14 16:11:19 +00:00
Karl Ramm
c5bb3aa547 mypy gets confused if you leave out 'self' (#1871) 2018-02-10 13:24:05 -08:00
Rhys Parry
6b82088e20 Add UserDict attribute data for Python 3 (#1863) 2018-02-09 07:55:58 -08:00
Chad Dombrova
ed9d08e93b Collections that inherit from dict should should override copy() (#1856)
Solves issue #1642. A previous attempt at this, #1656,
added __copy__ but omitted copy, and it did not properly use self-type.
2018-02-09 00:26:37 +00:00
George King
1533602779 filter function: make the callable of the first overload non-optional so that mypy is able to select the second overload for the case. (#1855) 2018-02-05 10:50:40 -08:00
Marti Raudsepp
15f07f5d03 Add ImportError attributes name, path for Python 3.3+ (#1849)
Reference: https://docs.python.org/3/library/exceptions.html#ImportError
2018-02-01 07:38:26 -08:00
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
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
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
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
Yuri Khan
732726400f Add stub for stat.filemode (#1837)
Fixes #1836.
2018-01-23 14:27:01 -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
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
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
Anthony Sottile
03044212d4 Add typings for bool __{r,}{and,or,xor}__ (#1795) 2017-12-20 21:04:55 -08:00
Semyon Proshev
4b6b484786 Add clear method to MutableSequence in Python 3 (#1765) 2017-12-15 19:37:43 -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
Sebastian Rittau
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 Yamamoto
39eefa544c Fix parameters of socketserver.BaseServer.finish_request() (#1754)
See also: python/cpython#4445
2017-11-21 16:42:05 -08:00
gossrock
15983ffc51 Add LINE and COL definitions to /stdlib/3/curses/__init__.py (#1757)
Fixes #1596
2017-11-20 13:44:20 -08:00
Ivan Levkivskyi
ec2cb8e44f Convert selected ABCs to Protocols (#1220) 2017-11-19 08:52:16 -08:00
Semyon Proshev
7c11ae03de Add __qualname__ to functions and methods (#1750) 2017-11-16 08:37:36 -08:00
Jelle Zijlstra
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 Zijlstra
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 Zijlstra
324f1761f4 Change more defaults to ... (#1727) 2017-11-09 10:32:17 -08:00
Jelle Zijlstra
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 Axtens
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
Jelle Zijlstra
eaf8972e48 complete Python 3 gzip stub (#1723)
* complete python 3 gzip stub
* IOBase.closed is read-only
2017-11-09 05:56:55 -08:00
Henri Bai
44f7869c80 Fix blake2 binding (#1663)
* Fix blake2 binding

Currently calling `hashlib.blake2b` results in the following type errors:

Cannot instantiate abstract class '_BlakeHash' with abstract attributes 'copy', 'digest', 'hexdigest' and 'update'
Missing positional arguments "data", "key", "salt", "person", "fanout", "depth", "leaf_size", "node_offset", "node_depth", "inner_size", "last_node" in call to "_BlakeHash"

* Additional changes to reflect the hashlib implementation

Modifies the type signatures of:
 * blake2b
 * blake2s
 * sha3_224
 * sha3_256
 * sha3_384
 * sha3_512
 * shake_128
 * shake_256
To reflect the types that are implemented in the standard library.
These should be exposed as `type`s instead of `builtin_function_or_method`s.
e.g.
In [40]: type(hashlib.blake2b)
Out[40]: type

In [41]: type(hashlib.md5)
Out[41]: builtin_function_or_method
2017-11-08 19:39:55 -08:00
Luka Sterbic
0a9a2b6470 _asdict returns OrderedDict in 3.1 and up (#1690) 2017-11-08 08:50:36 -08:00
Sebastian Steenbuck
2551b76bde Replace default strings ' ' with ... (#1721)
This fixes a problem with pytype.
2017-11-08 08:49:54 -08:00
FichteFoll
f933b9384c Refine str.maketrans and str.translate (#1613)
str.translate requires a Mapping or Sequence (in essence, anything
with __getitem__), not a Dict.

str.maketrans in the one-argument form only converts character string
keys to their unicode ordinal, leaving any of the values untouched.
This mapping may use both integers or strings as keys at the same time.

str.maketrans in the multi-argument form returns a dict with any of the
values str, int or None, as recognized by str.translate.
2017-11-07 18:55:05 -08:00
Sebastian Steenbuck
ef46c95c9e Add List to the typing imports and order the imports (#1717)
List is used but not imported. According to PEP-484 "Suggested syntax for Python 2.7 and straddling code" it should be imports. 

"Like other type comments, any names used in the annotations must be imported or defined by the module containing the annotation.".

Also order the typing import list, because it looks nicer.
2017-11-07 06:42:23 -08:00
Alan Du
275d9b5818 Python 3 multiprocesisng synchronization stubs (#1678)
* Add multiprocessing.Array to Python 3 stub

* Add Pipe and Connection type

* Add synchronize type-stub

* Add multiprocessing Exceptions

* Update context with synchronization primitives

* Code review comments

* Add acquire and release from _make_method

* Remove Array stub

* add missing Optional
2017-11-06 23:07:02 -08:00
Roy Williams
f4e3657c57 Allow subprocess functions to accept PathLike objects in 3.6 and above (#1713)
* Allow subprocess functions to accept PathLike objects in 3.6 and above

* Split up _PATH from _TXT in subprocess
2017-11-06 10:28:08 -08:00
Josh Staiger
bc2f88d6ee Make Executor.__enter__ self and return types match (#1711)
Specifically, this solves a problem in code such as:

with ThreadPoolExecutor() as p: ...

Where the p variable would be typed as an abstract `Executor`, rather than the specific `ThreadPoolExecutor` as expected.
2017-11-04 13:56:55 -07:00
anentropic
05f527c089 BaseException.__init__ accepts **kwargs (#1704) 2017-11-03 23:10:34 -07:00
Zac Hatfield Dodds
89cfa64577 Complete Py3 stub for sre_constants (#1709) 2017-11-03 22:48:10 -07:00
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