Commit Graph

312 Commits

Author SHA1 Message Date
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
Matthias Kramm
9c04490e92 add sys.setdefaultencoding() (#1865) 2018-02-08 11:25:48 -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
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
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
rchen152
29acda6431 Add itertools.imap signatures for more than two iterables. (#1815) 2018-01-04 19:03:41 -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
Anthony Sottile
03044212d4 Add typings for bool __{r,}{and,or,xor}__ (#1795) 2017-12-20 21:04:55 -08:00
Semyon Proshev
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 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
rchen152
8753fc78df Add setUpClass and tearDownClass to unittest.TestCase in Python 2 stub (#1760) 2017-11-21 16:39:11 -08:00
Ivan Levkivskyi
ec2cb8e44f Convert selected ABCs to Protocols (#1220) 2017-11-19 08:52:16 -08:00
Ethan Smith
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 Proshev
3029357ad7 Add unicode.__rmul__ (#1749) 2017-11-16 08:31:55 -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
Alex Willmer
55f15427bd Refine stdlib commands module (add mkarg(), mk2arg(), correct get*()) (#1739) 2017-11-12 22:44:51 -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
Alex Willmer
c7bc0bdb00 Add BaseException.__getitem__ & __getslice__ (#1719)
Refs python/mypy#4215
Fixes false positive

    error: Value of type Exception is not indexable
2017-11-07 12:57:51 -08:00
anentropic
05f527c089 BaseException.__init__ accepts **kwargs (#1704) 2017-11-03 23:10:34 -07: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
Guido van Rossum
05ffb1f912 Make initial_indent and subsequent_indent AnyStr in wrap() and fill() (#1662)
Leave them alone in TextWrap.__init__(), since I don't want to make the whole class generic.
2017-10-10 15:11:48 -07:00
Guido van Rossum
6d619e013c Add textwrap.dedent() to Py2 stubs (#1661) 2017-10-10 10:07:18 -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
Ashwini Chaudhary
c03e3a7ac0 Added stub for whichdb(py2) (#1508)
Added stub for whichdb(py2)
2017-10-06 19:04:18 -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
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
Matthias Kramm
03ec4023ff Adjust ast imports to make pytype happy. (#1617)
Turns out that pytype is a bit more finicky about imports, and
differentiates between '*' imports for export, and imports
for use in the local pyi. This adjusts ast.pyi to make pytype
understand it again.
2017-09-22 06:27:27 -07:00
Amandine Lee
248f74d31b ConfigParser should use IO[str] for IO functions (#1621) 2017-09-22 06:25:17 -07:00
David Novakovic
b4e89a078c Second param of islice allows None. (#1603) 2017-09-20 14:55:16 -07:00
rchen152
3d505d0c6b Re-export exception names in exceptions.pyi (#1611) 2017-09-19 15:19:40 -07:00
rchen152
c009caf316 Make exceptions.pyi import its definitions from __builtin__.pyi (#1610)
* Make exceptions.pyi import its definitions from __builtin__.pyi

* Make ReferenceError a full class again.

* Restore blank line at EOF.
2017-09-15 14:52:54 -07:00
rchen152
0bf2958257 Correct a typo in stdlib/2/symbol.pyi (#1607) 2017-09-14 14:33:20 -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
rchen152
fd8be43044 Fix the return type of functools.update_wrapper() (#1589) 2017-09-05 20:03:51 -07:00
rchen152
8d5a233c6b Fix the definition of itertools.tee() (#1584) 2017-09-05 16:21:14 -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
1c8f43b86c Add closefd keyword argument to Python 2's FileIO.__init__ (#1555)
Fixes #1553.
2017-08-17 20:47:08 +02: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
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
Ashwini Chaudhary
0c7b50378b Added stub for mutex(py2) (#1509) 2017-08-02 08:32:10 -07:00
Ashwini Chaudhary
01a0c51acf Added stub for sre_parse and sre_constants(py2) (#1500)
* Added stub for sre_parse (py2)

* Added missing import

* Added missing hints; Fixed _AvType and _TemplateType

* Added stub for sre_constants
2017-08-01 14:38:22 -07:00