Commit Graph

424 Commits

Author SHA1 Message Date
Sebastian Rittau
eb1788ac39 Merge Python 2 and 3 builtins.pyi (#2533) 2018-12-21 07:12:41 -08:00
Dave Halter
2cedbc7d63 Add missing attributes of type (#2544)
All these attributes can be seen when using `dir(type)`.

In the future we should be discussing if certain methods on object (like
__eq__) should really be there. IMO this should be defined on type where it
actually also appears when using `dir`.
2018-12-20 20:01:40 -08:00
Juan Gonzalez
c18b75b2e6 Make mypy aware of IMapUnorderedIterator (#2701) 2018-12-20 19:41:58 -08:00
Dave Halter
5c69373890 macpath, os/path, posixpath and ntpath should basically be the same files (#2637) 2018-12-17 15:02:18 +01:00
Michael J. Sullivan
95afb86022 Move posix.stat_result to os.stat_result on python 3 (#2683)
In python 3, posix.stat_result is a re-export of os.stat_result, while
in python 2 it was the reverse. Update typeshed to reflect this.
2018-12-13 19:20:42 +01:00
Philipp Hahn
d57e8c69f3 urllib2: timeout: int -> Optional[float] (#2685) 2018-12-12 15:47:53 +01:00
Guido van Rossum
e08a5ac367 Tweak how ast.pyi imports typing (#2668)
When we import typeshed internally at Dropbox, somehow the fact that
these files are all stubs gets lost (it's a long story...).  This
causes errors like this:

  .../stdlib/2/ast.pyi:6: error: Name 'typing' already defined (by an import)

The quickest way around this is to rename the import to _typing.
2018-12-04 17:25:23 +01:00
Utkarsh Gupta
3e4737c683 ast.pyi: Fix return type of generic_visit() (#2667)
Fixes #2085
2018-12-04 08:02:39 +01:00
Guido van Rossum
de50614957 Stop inheriting Sized in collection ABCs (#2658)
Instead define abstract __len__ in affected classes.

Fixes #2655 without breaking
https://github.com/rominf/ordered-set-stubs/issues/1
2018-11-30 13:10:35 -08:00
Jukka Lehtosalo
eaeb5fcf13 Revert "Move Sized earlier in the bases of Sequence (#2602)" (#2657)
This reverts commit 4dc21f04dd.

Fixes #2655.
2018-11-30 14:48:55 +00:00
Jukka Lehtosalo
84548f5bba Revert "fix list concatenation (#2404)" (#2653)
The fix caused regressions for mypy that are difficult to
fix.  See https://github.com/python/mypy/issues/5492 for
context.

This reverts commit 1a42a2c3ea.
2018-11-29 12:20:29 -08:00
anentropic
98e63d2d2f staticmethod and classmethod can wrap any callable (#2650)
Closes: #2645
2018-11-29 14:36:08 +01:00
Michael R. Crusoe
48183b1d27 Unicode fixes for url2pathname() and pathname2url() (#2555) 2018-11-29 14:28:07 +01:00
Brandt Bucher
1857435e6f types.CodeType.co_filename isn't Optional. (#2639) 2018-11-27 20:53:05 -08:00
Dave Halter
84daf7c93b Add __getnewargs__ to float, int, bool, str, bytes, unicode (#2632) 2018-11-26 10:43:12 +01:00
Sebastian Rittau
517d2b6012 Remove unneeded ignores (#2624) 2018-11-23 09:51:44 -08:00
Brandt Bucher
7685462672 Add complete annotations to builtins.compile. (#2606) 2018-11-20 17:48:24 +01:00
Sebastian Rittau
cd75801aa5 Replace non-ellipsis default arguments (#2550) 2018-11-20 07:35:06 -08:00
Guido van Rossum
4dc21f04dd Move Sized earlier in the bases of Sequence (#2602)
See https://github.com/rominf/ordered-set-stubs/issues/1:
class OrderedSet(MutableSet[T], Sequence[T]): ...
works in Python 3, but not in Python 2 -- this fixes that
2018-11-13 20:47:48 -08:00
Gregory P. Smith
5d85326ad8 Expand Python 2's urllib.addbase definition. (#2601)
Give it enough information to determine that addinfourl
is iterable and that iteration and read methods return bytes.

Modeled after what is in stdlib/3/urllib/response.pyi after confirming
by looking at Python 2.7 stdlib code.
2018-11-13 11:04:12 +01:00
Gregory P. Smith
cd4572e43c Annotate some missing http client and urllib APIs. (#2582) 2018-11-12 21:54:57 +01:00
Jelle Zijlstra
1a42a2c3ea fix list concatenation (#2404)
Fixes #2383, python/mypy#5492.
2018-11-08 06:42:57 -08:00
Michael J. Sullivan
ffeede30d2 Make SyntaxError.offset be optional (#2557) 2018-10-25 13:54:55 -07:00
Sebastian Rittau
006a79220f Flake8 fixes (#2549)
* Fix over-indented continuation lines

* Fix under-indented continuation lines

* Fix whitespace around default operator problems

* Limit line lengths

* Fix inconsistent files
2018-10-24 07:20:53 -07:00
Michael J. Sullivan
4badd35325 Allow json.dump to dump to BinaryIO again (#2546)
PR #2516 aimed to widen the accepted file argument to json.dump, but
since `IO` is invariant in its argument, it actually disallowed
passing binary files.
2018-10-23 16:13:07 -07:00
Jelle Zijlstra
63cf7f529b fix lint error (#2541) 2018-10-23 14:00:26 +02:00
Dave Halter
a437fcc886 Add attributes to int and float (#2529)
* real, imag, conjugate all exist on int and float
* numerator, denominator exists on int
2018-10-23 00:44:36 +02:00
Lourens Veen
703c03e4b0 Add UserString and UserList data attribute (#2518) 2018-10-16 10:36:17 +02:00
Siva Chandra
cec2202550 Widen the type of the file argument to Python 2's json.dump. (#2516) 2018-10-12 15:58:46 -07:00
Semyon Proshev
4859742087 Inherit InstanceType from object (#2511) 2018-10-08 14:31:21 +02:00
Jelle Zijlstra
bc3f9fe1d3 fix typing.Pattern in Python 2 (#2219)
Fixes #2199
2018-10-01 20:35:13 -07:00
Richard Levasseur
4122a70648 Add some private methods to unittest (#2494)
This adds a few stubs that are used by absl-py, and, without them, cause
type checker errors under Pytype:
 * TestCase._formatMessage
 * TestCase._testMethodName
 * TestCase._getAssertEqualityFunc
 * TestProgram.runTests
2018-10-01 20:18:26 -07:00
Israel Tsadok
2a30462c4a The filter function may return str, tuple or list (#2472)
In Python 2, the return type of filter depends on the iterable
parameter.
2018-09-25 20:26:23 -07:00
Michael J. Sullivan
65863bebf4 make __class__ refer to the current object's class (#2480)
This is just a direct rehash of #1549.
2018-09-25 18:04:37 -07:00
Michael R. Crusoe
2e0af18dda slices of MutableSequences are also MutableSequences (#2428) 2018-09-25 13:06:59 -07:00
Sebastian Rittau
ea2122741f os.path.exists (Py 3) accepts a file descriptor (#2451)
Closes #1653
2018-09-24 07:53:44 -07:00
Michael J. Sullivan
4f4a025409 Remove tuple's __init__ method (#2467)
The __new__ method should suffice, and having both interferes with providing
a __new__ in namedtuples, which we want to do to fix
https://github.com/python/mypy/issues/1279.
2018-09-18 20:01:14 -07:00
Rebecca Chen
b7c262523b Fix the Python 2 signature of tempfile._TemporaryFileWrapper.write. (#2465) 2018-09-18 13:54:56 +02:00
Sebastian Rittau
44bdf6c6c7 Fix RawConfigParser.readfp() annotation (#2443)
Closes #689
2018-09-11 08:22:36 -07:00
Jelle Zijlstra
8b9e4c378a fix module argument to unittest.main (#2403) 2018-09-10 11:04:05 -07:00
Ilya Konstantinov
fe04d3aa2d Accept str in cast (#2408) 2018-08-21 07:53:35 -07:00
Jelle Zijlstra
9e023e7586 minor namedtuple fixes (#2227)
- The extra arguments aren't keyword-only in 2.7.
- Added the `defaults` argument in 3.7 (https://docs.python.org/3.7/library/collections.html#collections.namedtuple).
2018-08-19 03:47:10 +01:00
Teddy Sudol
0386f3daec Change mode: unicode to mode: Text (#2398)
Resolves #2397
2018-08-17 16:33:35 -07:00
Sebastian Rittau
25ac4d6af4 Implement StartResponse using a protocol (#2392)
* Add ExcInfo and OptExcInfo type aliases

* Implement StartResponse using a protocol

* Mark stub-only types with an underscore

* Remove wrong TODO note

python/mypy#1178 is about variable-length tuples, while exc_info()
always returns a tuple with length 3. Ideally, exc_info() would
return Union[Tuple[Type[_E], _E, TracebackType], Tuple[None, None, None]],
but that is a different issue.
2018-08-17 08:36:00 -07:00
Michael Lee
bc8d68cd34 Add constructor for HTTPError in urllib2/urllib.error (#2373)
It seems that code using HTTPError previously worked by accident
because we used to accept arbitrary keyword arguments when
instantiating BaseException, or any subclass of BaseException
(see https://github.com/python/typeshed/pull/2348).

This commit adds in the correct constructor (which also lets the
user specify the arguments in keyword-argument form).

Note: I'm not very familiar with the urllib libraries, so I opted
to just add the signature and leave it up to somebody else to
fill in the types.
2018-08-08 17:05:35 -07:00
David Euresti
4e40b035c8 BaseException does not take keyword arguments (#2348)
Fixes #2344
2018-07-27 13:28:43 -07:00
Ville Skyttä
f5fc356928 markupbase: Fix unkown_decl typo (#2342) 2018-07-21 23:37:21 -07:00
Omar Sandoval
42db5ad4f7 Add missing int.__index__() signature (#2335)
This has been present since Python 2.5.
2018-07-16 15:30:06 -07:00
Ethan Smith
cc45366ca5 Merge 2/genericpath and 2and3/genericpath (#2330) 2018-07-13 14:07:15 -07:00
Sebastian Rittau
a38dbc6c1e Merge decimal (#2306) 2018-07-09 19:03:01 -07:00