Commit Graph

328 Commits

Author SHA1 Message Date
Guido van Rossum
30791d4208 Give Python 2 sys.getprofile() and sys.gettrace() return types (Any). (#1988)
(In Python 3 their types are already correct.)
2018-03-26 18:37:04 -07:00
Tuomas Suutari
4da20cb8b7 multiprocessing: Fix timeout args of AsyncResult methods (#1984)
The timeout argument of wait and get methods of AsyncResult accepts also
None so fix the type specification to include Optional.

Accepting None is not an implementation detail as it's clearly
documented too:

https://docs.python.org/2/library/multiprocessing.html#multiprocessing.pool.AsyncResult

https://docs.python.org/3/library/multiprocessing.html#multiprocessing.pool.AsyncResult
2018-03-24 08:15:39 -07:00
Ashwini Chaudhary
164aa21fa1 Added stub for dircache(py2) (#1510) 2018-03-17 22:22:25 -07:00
z33ky
c2c48424da Add missing collections.defaultdict.__init__ overloads (#1957) (#1958) 2018-03-17 08:22:11 -07:00
Svyatoslav Ilinskiy
d702d3621c Complete stubs for email package in python2 (#1936)
Fix #685, fix #275
2018-03-06 21:38:01 -08:00
rchen152
38dc8f5a6a Switch usages of mypy_extensions.NoReturn over to typing.NoReturn. (#1942)
* Change mypy_extensions.NoReturn to typing.NoReturn everywhere.
2018-03-05 12:42:29 -08:00
Takuya Akiba
7e169a29c2 Add multiprocessing.pool to Python 2 stub (#1932) 2018-02-28 11:22:11 -08:00
rchen152
066c434410 Improve the unittest stubs. (#1927)
* Improvements to stdlib/2/unittest.pyi

* Adds a bunch of missing things.
* Fixes the signatures of assertRaises and failUnlessRaises.
* Corrects the name of a TestCase subclass from CallableTestCase
  to FunctionTestCase.
* Makes defaultTestLoader an instance of TestLoader, as it should
  be, rather than an alias. Based on https://docs.python.org/2/library/unittest.html and
  https://github.com/python/cpython/tree/2.7/Lib/unittest.

* Improvements to stdlib/3/unittest/__init__.pyi

* The constructor arguments to TextTestResult are all required.
* There is a module-level load_tests() function.
* removeResult() returns a bool. Based on https://docs.python.org/3/library/unittest.html and
  https://github.com/python/cpython/tree/master/Lib/unittest.
2018-02-27 06:46:10 -08:00
Sebastian Rittau
38aea73b4b Merge Python 2 and 3 versions of time.pyi (#1909)
* Use variable annotations
* Replace default values by ellipses
* Remove exceptions from function bodies
* Remove superfluous comments
* Remove superfluous newlines
* Use Optional instead of Union[..., None]
* Replace Union[int, float] by just float

* Make time.pyi (Python 2) more closely resemble the Python 3 stub

* Replace _TIME_TUPLE by TimeTuple
* Reorder imports

* time.pyi: Mark two arguments as optional, mark Unix-only function

* time.pyi (Python 2): Use TimeTuple in NamedTuple and reformat

This makes time.pyi more closely match the Python3 version.

* Merge Python 2 and 3 versions of time.pyi

* Only import SimpleNamespace on Python >= 3.3

* Remove default values from module properties

* Remove Optional from strftime() and asctime()

* accept2dyear was removed in Python 3.3

* Rename TimeTuple to _TimeTuple
2018-02-24 11:49:37 -08:00
Daniel Li
84b6e95bdc Accept unicode in importlib.import_module (#1910)
On Python 2, importlib.import_module accepts bytes or unicode.
2018-02-22 09:05:06 -08:00
shahin
d3a9650fa1 Fix return type of re.match, re.search (#1886) 2018-02-19 09:23:57 -08:00
David Euresti
8ecb74012a Add __divmod__ to numeric types (#1900)
Helps with #1889
2018-02-18 16:59:12 -08:00
Guido van Rossum
37ec012113 Change the type of BaseException.message to Any (#1887) 2018-02-16 13:42:28 -08:00
Guido van Rossum
100a071729 Make the urllib.quote/unquote functions generic (#1891)
When given unicode they will return unicode.
Also make 'safe' Text.
Fixes #1893.
2018-02-16 13:14:05 -08: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
Matt Bogosian
afc84c119c Add TestCase.longMessage to stdlib/2/unittest.pyi (#1875)
Fixes #1874.
2018-02-11 16:16:35 -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
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