Commit Graph

344 Commits

Author SHA1 Message Date
Jelle Zijlstra
55be42f6d6 add __fspath__ support to os.path (#2053)
Fixes #1997, #2068.

This is tricky because we need to get the return values right (see #1960 for
prior attempts) and we often run into python/mypy#3644. I found that I
could express most signatures correctly using a series of overloads.

A few other changes in here:
- Added splitunc, which according to https://docs.python.org/3/library/os.path.html
  should exist in both Unix and Windows.
- Made the second argument to os.path.curdir Optional to match the implementation.
- Fixed os.path.split, whose previous Path-aware signature triggered python/mypy#3644.
2018-05-15 10:31:40 -04:00
Sebastian Rittau
09008599ce Merge Python 2 and 3 wsgiref (#2106)
* Merge Python 2 and 3 wsgiref

* Move wsigref to 2and3
2018-05-09 16:26:03 -07:00
Guido van Rossum
d854d7e2a0 Revert "Fix signature of generic_visit method (#2100)" (#2101)
This reverts commit 39576c5d41.

I merged too soon -- tests are failing.
2018-05-07 11:21:19 -07:00
Thomas Schaper
39576c5d41 Fix signature of generic_visit method (#2100)
This methods returns something that has the same type as the first argument.
Fixes #2085.
2018-05-07 11:20:20 -07:00
Jelle Zijlstra
9e25506cab add missing attributes to Python 2 unicode errors (#2084) 2018-04-27 14:37:20 -07:00
Martin DeMello
2935017157 Add multiprocessing.dummy pyi files (#2059) 2018-04-18 19:20:01 -07:00
Jelle Zijlstra
a5429d25dc add missing methods to DictMixin (#2054)
Fixes #1896.
2018-04-14 14:21:07 -07:00
Jelle Zijlstra
0f425db197 fix types for unittest.TestLoader.loadTestsFrom* methods (#2042)
Fixes #2008.
2018-04-12 12:29:32 -07:00
Svend Sorensen
6c1dffed58 Make islice start and stop parameters optional (#2031)
From the documentation [1]: "If start is None, then iteration starts at zero."

[1] https://docs.python.org/3/library/itertools.html#itertools.islice.

PR #1603 made this change for Python 2.
2018-04-10 20:55:06 -07:00
Jelle Zijlstra
f37709f9c3 Merge stubs for sqlite3 (#2026)
As promised in #2014.

There are virtually no real changes between Python 2 and 3 in this module, but the stub had accumulated some meaningless differences. I also fixed a few incorrect types.
2018-04-09 12:32:59 -07:00
Jelle Zijlstra
d43eac60dd add email.parser.FeedParser (#2028)
Fixes #1985.
2018-04-09 12:03:43 -07:00
Jelle Zijlstra
4ab720161a ResourceWarning doesn't exist in Python 2 (#2020)
Fixes #1971.
2018-04-06 11:19:34 -07:00
Jelle Zijlstra
ce0656a8c7 add some more Python 3.7 features (#2014) 2018-04-06 11:08:30 -07:00
Alan Du
bd26c7bf84 Add __complex__ to complex (#2004)
* Add __complex__ to complex

complex SupportsComplex!

* Allow constructing complex from SupportsComplex
2018-04-03 07:14:52 -07:00
Jelle Zijlstra
103056eecf fix some TODOs (#1994)
- Made deque.maxlen read-only
- We don't support 3.2, so we don't care about signature changes in it
- There don't seem to be any missing set operations (I compared the dir() of this class to that of builtins.set)
2018-03-28 18:40:13 -07:00
Semyon Proshev
ac70fdc614 Overloads for map (#1990) 2018-03-27 10:05:59 -07:00
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