Commit Graph

275 Commits

Author SHA1 Message Date
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
Matthias Kramm
6f23d124c0 Remove subclass IOBase from TextIOBase. (#1505)
This used to cause TextIOBase to subclass both BinaryIO and TextIO, even
though those two are incompatible.
2017-07-28 21:07:37 -07:00
Semyon Proshev
72fbc459a7 Add __init__ to types.MethodType (#1499) 2017-07-26 08:38:27 -07:00
Thomas Grainger
15c8474e35 fix email.mime (#1482)
* add missing python 2 email.mime.application stub

* restore missing python 3 mime package

* Delete __init__.py
2017-07-26 08:29:30 -07:00
Michael Lee
6d3024fb19 Add NoReturn type to typing stubs (#1496) 2017-07-20 21:24:34 -07:00
Jelle Zijlstra
be7490322b Counter: fix return value of most_common() (#1491)
https://docs.python.org/3/library/collections.html#collections.Counter.most_common
https://docs.python.org/2/library/collections.html#collections.Counter.most_common
2017-07-19 20:29:32 +03:00
Jelle Zijlstra
00ddb1c84a encodings: IncrementalEncoder and Decoder concrete (#1490)
These stubs are identical in Python 2 and 3, but I believe they
should not be merged, because there are numerous other modules
in the encodings package, and some only exist in some Python
versions. I don't think we can support that in the 2and3
directory.
2017-07-19 20:28:43 +03:00
Ashwini Chaudhary
a4a34a0e73 Added stub for stringold module (#1460) 2017-07-16 15:08:27 -07:00
rchen152
643aedea1b Fix the definition of LockType.__exit__. (#1485) 2017-07-13 17:30:51 -07:00
rchen152
6368baf42a Remove duplicate names from posixpath.pyi. (#1468)
posixpath.pyi did a '*' import of genericpath.pyi and then redefined
everything it imported. Removes the duplicate definitions from posixpath
and improves the ones in genericpath.
2017-07-06 14:22:18 -07:00
Jelle Zijlstra
16aa0651ae Revert "Add __new__ to str and int stubs in both Pythons. (#1352)" (#1466)
This reverts commit fed4e03e53.
2017-07-06 14:21:54 -07:00
Ashwini Chaudhary
1a9685c6ce Added stub for Python 2's _threading_local (#1461) 2017-07-04 20:01:17 -07:00
Jelle Zijlstra
318cada66c os: merge the top and bottom of os/__init__.pyi (#1458)
* os: merge the top and bottom of os/__init__.pyi

Part of #1427. In preparation for merging the two stubs, I'm making the files
identical as much as possible. This PR merges the top of the file, down to
but not including the definition of statvfs_result, and the bottom up to
and including os.utime.

This PR mostly adds more "if sys.version_info" block. Until the merger
completes, we'll have some Python 2 blocks in the Python 3 stub and vice versa.
I also add a few missing constants and arguments.

In followup PRs I'll merge the rest of the file. I'll put the trickiest part
(the return values of functions like os.stat) in its own PR.

* back out DirEntry from py2

It relies on stat_result which we don't have yet in py2.
2017-07-04 19:30:55 -07:00
Jelle Zijlstra
a419b696d4 make os.path identical in Python 2 and 3 (#1459)
Part of #1427. I don't think we can actually merge these until we merge
os/__init__.pyi too, which will take a few more PRs.
2017-07-04 19:27:27 -07:00
Jelle Zijlstra
f264eda4ed builtins: mode argument to open can be unicode (#1452)
Part of #1411

Also remove some explicit parameter defaults.
2017-07-04 19:20:45 -07:00
Jelle Zijlstra
9947c9d513 urlparse: allow unicode arguments in more places (#1451)
* urlparse: allow unicode arguments in more places

Part of #1411

urlunsplit() and similar functions accept either unicode or str in all
places. Their actual return type is unicode if any of the arguments is
unicode and nonempty, which the type system can't exactly express. I
left the return type as str because str is implicitly promoted to
unicode, so using the return type in a place that accepts unicode should
work.

unquote, parse_qs, and parse_qsl return unicode if you pass them unicode,
so AnyStr is appropriate in their stubs.

* fix type for urldefrag

The return type was wrong; this function returns a 2-tuple. The second member of the tuple is always a `str` if the argument type does not contain '#', and otherwise matches the type of the argument.
2017-07-04 19:20:23 -07:00
Ivan Levkivskyi
97737ce8c2 Add collections import in typing for type aliases to always work (#1456)
* Add collections import in typing for type aliases to always work

* Add mypy issue number to the comment
2017-07-03 10:01:19 -07:00
Ashwini Chaudhary
83d5ba157c Added stub for toaiff module (#1455) 2017-07-02 21:24:21 -07:00
Ashwini Chaudhary
489696e9a1 Added stub for user module (#1454) 2017-07-02 15:17:37 -07:00
Peter Vilim
bc9b2f0d4d Fix signature for slite3.fetchmany (#1444)
Also made pymssql.fetchmany simpler.
2017-06-29 15:05:47 -07:00
Roy Williams
ac87de50dd Add __name__ field to MethodType (#1442)
See 08c16016e2/Lib/types.py (L32-L34)

```python
>>> class _C:
...     def _m(self): pass
...
>>> _C()._m.__name__
'_m'
```
2017-06-29 10:05:25 -07:00
Roy Williams
31d7393cae Support calling eval and ast module with unicode in Python 2 (#1440) 2017-06-26 19:06:17 -07:00
mistermocha
5306d6f5a7 Correct implementation of standard types besides "object" (#1340)
Per https://github.com/python/mypy/issues/2989
2017-06-23 09:45:48 -07:00
Jelle Zijlstra
4a5ff0bb11 use PEP 526-style annotations in os stubs (#1428)
And fix some TODOs.

This will help me check these stubs with my stubcheck tool, and is better
for consistency anyway.
2017-06-22 05:49:23 -07:00
Matthias Kramm
c4e0580a4a make io.pyi import everything from _io.py(i), like io.py does (#1395)
* make io.pyi import _io.py(i), like io.py does
* make write/writelines take 'Any', on _IOBase
* Add missing constructors, fix inconsistencies.
* Also, as far as possible, try to simplify, by moving methods into base
classes.
* fix lint+mypy warnings
* add missing __enter__ methods
* make _IOBase inherit from BinaryIO
* make _TextIOBase not subclass _IOBase
2017-06-21 20:04:04 -07:00
Guido van Rossum
04fe184dcf Add flags to pass on --warn-unused-ignores and --no-implicit-optional to mypy (#1421)
* Add flags to pass on --warn-unused-ignores and --no-implicit-optional to mypy
* Make implicit Optional explicit in arg types (2and3 part)
* Convert {stdlib,third_party}/2 to explicit Optional
2017-06-20 22:18:49 -07:00
Guido van Rossum
86070643ac Improve csv module and float() signature (#1418)
* DictReader should not be abstract. Reformat long lines.
* Make restval optional for DictWriter.__init__.
* The arg to reader() is *Iterable*, not *Iterator*.
* Improve signature of float() (use Union instead of overload).
2017-06-20 13:04:10 -07:00
rchen152
945527dbc0 Add a __new__ method to datetime.datetime. (#1417) 2017-06-19 17:05:34 -07:00
Yusuke Miyazaki
1c8498228d Update stub for csv (#1398) 2017-06-15 16:35:17 -07:00
Matthias Kramm
5d1aacfed3 special-case overload for itertools.product with 'repeat' (#1410)
Add an additional overload for the `repeat = n` case. Since we don't know 
the numeric value of `repeat`, this just produces an iterator over an 
arbitrary-length tuple.
2017-06-15 19:13:46 +01:00
Guido van Rossum
4fbdcf5b03 Revert "add back 'repeat' argument to itertools.product (#1407)" (#1409)
This reverts commit d5e7663f93.
2017-06-14 13:10:29 -07:00
Matthias Kramm
d5e7663f93 add back 'repeat' argument to itertools.product (#1407)
Fixes a regression introduced by #1393.
2017-06-14 09:33:37 -07:00
Semyon Proshev
fed4e03e53 Add __new__ to str and int stubs in both Pythons. (#1352)
* Update default values to `...` in `__init__` and `__new__` in `int` and `str`.
* Add `__new__` to `enum.IntEnum` to override inherited `__new__`.
* Add `type: ignore` comment to `IntEnum`
2017-06-12 20:53:32 -07:00
Matthias Kramm
ed6dc176da make itertools.product more precise (#1393) 2017-06-12 20:10:08 -07:00
Matthias Kramm
d4c13e73f9 gzip.GzipFile.__init__ accepts any Text for 'mode' (#1403) 2017-06-12 15:36:47 -07:00
rchen152
16ec7cbdf0 Add __new__ to time.struct_time (#1394)
This is needed because otherwise pytype uses the `__new__` inherited from the `NamedTuple` base class.
2017-06-06 15:36:01 -07:00
pkordas
4dd40465e7 added stub file for popen2 (#1385) 2017-06-05 12:27:34 -07:00
amstree
1d4c73d708 Fix type annotations for glob (#1386) 2017-06-02 21:05:21 -07:00