Commit Graph

296 Commits

Author SHA1 Message Date
Guido van Rossum
8be390d2a6 Improve signature of communicate().
The input type can be bytes or unicode, the return types are always Optional bytes.
2016-09-19 15:17:09 -07:00
Guido van Rossum
794e51612e Improve signatures of {get,set}sockopt(): use bytes, not str. 2016-09-19 15:17:09 -07:00
Samuel Colvin
773ad48c04 correct utcoffset return type (#554) 2016-09-18 13:44:38 -07:00
Elazar
1d820d48cf Add signatures for cast() and NewType (#549)
(Mypy ignores these in favor of hard-coded behaviors, but the signatures here may be useful for other tools.)
2016-09-14 14:55:06 -07:00
Michael Lee
748428d8a4 Refine stubs for Python 2's decimal module (#545)
* Refine stubs for Python 2's decimal module

The decimal module for Python 2 was relatively incomplete, unlike the
decimal module for Python 3. This commit copies the relevant type
signatures from Python 3's decimal module to Python 2's.

There was a lot of code in both stubs and it wasn't clear to me if it
was safe to merge the two modules together, so I refrained from doing
so.

* Allow comparisions with Decimals and Floats

This commit loosens the types for Decimals to allow comparisons like
`Decimal('3.14') < 4.2`. Previously, you could compare decimals with
only other decimals or ints.
2016-09-14 09:40:14 -07:00
Michael Lee
f29a996501 Refine stubs for numbers.pyi (#543)
* Partially refine numbers.pyi

This commit refines numbers.pyi. More specifically, it...

- Adds in explicit type annotations where it's obvious how to do
  so (leaving more non-obvious type signatures alone).
- Adds in missing '@abstractmethod' decorators
- Combines together the Python 2 and Python 3 versions of numbers.pyi.

* Merges Python 2 and Python 3 numbers.pyi

This commit removes the old `stdlib/2.7/numbers.pyi` file and moves the
previously-committed `stdlib/3/numbers.pyi` to the shared `2and3`
directory.

* Modify comment at top of numbers.pyi

Since the stubs are no longer identical to what stubgen creates, the
comment should also probably be changed.
2016-09-14 08:12:36 -07:00
Elazar
e25b882041 Full signature for namedtuple (#541) 2016-09-13 16:17:26 -07:00
Guido van Rossum
312725ed5d Add next() to more IO classes 2016-09-13 11:48:50 -07:00
Guido van Rossum
8b0e6b886d Fix signature for __exit__ (#542) 2016-09-13 11:00:01 -07:00
Guido van Rossum
0907e2cdda Add missing BytesIO.next(). 2016-09-12 12:24:06 -07:00
Alvaro Caceres
ecc400f125 Make string.Template.substitute's arg optional (#535) 2016-09-12 11:12:28 -07:00
Michael Lee
7a48825938 Copy stubs for os.spawn* from Python 3 to Python 2 (#528)
The stubs for the os module in Python 2.7 were somehow missing the
spawn* functions that were added to Python 3.
2016-09-09 12:00:00 -07:00
Alvaro Caceres
43fee3bc72 Declare 2.7 unittest's private util module (#526) 2016-09-09 06:30:58 -07:00
Guido van Rossum
25cb6e4ab4 Make Mapping covariant. (#512)
* Make Mapping covariant.

Fixes #510.

This requires a `# type: ignore` on `__getitem__` and `get` because
mypy complains about covariant parameters.

FWIW typing.py needs to be changed too.  (It was covariant in the
value but invariant in the key -- typeshed was invariant in both.)

* Delete outdated comment.

* Backpeddle a bit -- Mapping key type should not be covariant.
2016-09-05 20:57:37 +01:00
Valérian Rousset
1d5b35b2a5 Merge tarfile (#467) 2016-09-03 08:40:45 -07:00
Alvaro Caceres
23c44d3e36 Use generics for 2.7/weakref (#516) 2016-08-31 18:48:45 -07:00
Alvaro Caceres
79a9ae942e Add DictMixin, IterableUserDict to 2.7/UserDict (#513) 2016-08-31 11:12:34 -07:00
Matthias Kramm
044d11f9ee clean up unittest.py (#509)
* clean up unittest.py

Remove duplicates, adjust wrapping.

* also remove unittest from pytype blacklist
2016-08-31 07:27:53 -07:00
Michael Lee
97bc450acd Make typing.IO inherit Iterator, not Iterable (#502)
In Python, it's possible to use the `next` builtin method on file
objects produced by `open`. This change modifies `typing.IO` so this
usage will successfully typecheck.
2016-08-27 23:31:16 -07:00
David Euresti
5e5b3726f2 Add missing Optional to str.split and socket.socket. (#504)
* Add Optional to str.split and friends

* Python 3: Make fileno arg of socket.socket Optional
Python 2: Remove fileno arg of socket.socket
2016-08-27 19:09:55 -07:00
David Fisher
e8df136ce8 Fix incorrectly Optional builtin function args (#500)
Many builtin functions were accidentally marked as Optional because
they were given default values of None.
2016-08-25 19:07:00 -07:00
Valérian Rousset
9f1e90b33f Merge bisect (#468)
* merge bisect

* comment while mypy#2035
2016-08-24 06:07:40 -07:00
Tomasz Elendt
34175b888d Fix __setitem__(slice, ...) of various mutable sequences (#496)
Adds support of assigning iterables to slice of mutable sequences and
bytes to bytearray's slice.
2016-08-23 19:02:50 -07:00
David Euresti
ed7c0779f7 Add memoryview class for python 2.7 (#493) 2016-08-23 18:48:10 -07:00
peterdotran
aef68f323f Added attributes for URLError and HTTPError (#494) 2016-08-23 17:55:51 -07:00
Nicholas Bishop
a20d5c481a Add type stub for typing.get_type_hints (#480)
Fixes issue #477
2016-08-16 20:41:01 -07:00
kosaka
5a79ba1abb Fixes tzinfo return types (#476) 2016-08-16 08:07:00 -07:00
tonygrue-dbx
219c57a28c Add winerror to WindowsError in builtins.pyi for Python 2.7 and 3 (#470)
Adds the int type member to WindowsError stub
2016-08-15 11:41:05 -07:00
David Euresti
69fdea09c9 Fix some type errors in gettext in python2. (#469)
Also makes it look more like the python3 version
2016-08-15 11:40:16 -07:00
Emanuel Barry
0989cb1cb3 Add FrozenSet to the typing stub files (#474) 2016-08-13 19:34:38 -07:00
Valérian Rousset
2824cd1197 Improve locale (#462) 2016-08-10 13:52:29 -07:00
Valérian Rousset
04d799f656 fix unprecise type in sys.exc_info in py2 (#466) 2016-08-10 13:37:01 -07:00
Jakub Stasiak
0edb87fc6b Make functools.cmp_to_key more realistic (#458)
The documentation[1] says:

    A comparison function is any callable that accept two arguments,
    compares them, and returns a negative number for less-than, zero for
    equality, or a positive number for greater-than.

This doesn't seem possible with the comparison function defined as
returning bool.

[1] https://docs.python.org/3.6/library/functools.html#functools.cmp_to_key
2016-08-10 12:12:52 -07:00
Jakub Stasiak
f3818cabbc Handle passing a tuple of types to issubclass() (#459)
It can't be just any sequence hence Tuple is used instead of previously
mentioned Sequence.
2016-08-10 12:09:16 -07:00
Valérian Rousset
4e55f0561f Improve traceback (#465) 2016-08-10 11:18:35 -07:00
David Fisher
f209136b3c Make appropriate Popen constructor args Optional (#457) 2016-08-08 20:14:13 -07:00
Fu Yong Quah
6c1a185e49 Add exception globals in 2.7/sys.pyi. (#440) 2016-08-05 12:04:57 -07:00
David Euresti
89091458ed Fix Tuple being imported twice in ast.pyi (#442) 2016-08-05 06:54:01 -07:00
Matthias Kramm
b46658c104 remove stray ',' 2016-08-04 15:40:12 -07:00
Valérian Rousset
2e560d38dc Improve distutils (#418)
* remove old distutils

* core done

* ccompiler done

* compilers done

* archive_util done

* dep_util done

* dir_util done

* file_util done

* util done

* dist done

* debug, error, extension done

* fancy_getopt done

* filelist, log, spawn done

* sysconfig done

* text_file done

* version done

* cmd done

* add command

* add emxccompiler which is py2 only

* command.build_py have spec only in py3

* make pytype happy by resolving relative import
2016-08-03 15:38:15 -07:00
Guido van Rossum
6e596e9609 Fix decimal and contextlib (#428)
* Decimal does not support __round__, and its __abs__ returns Decimal.

* Fix contextmanager signature too.
2016-08-02 07:39:13 -07:00
Valérian Rousset
ee02a8a968 Improve threading (#403)
* initial stubgen

* comment everything

* 17.1.0 done

* 17.1.1 done

* 17.1.2 done

* 17.1.3 done

* 17.1.4 done

* 17.1.5 done

* reorder __enter__, __exit__

* 17.1.6 done

* 17.1.7 done

* 17.1.8 done

* 17.1.9 done

* cleanup, py3 done

* py2 begin, comment everything

* 16.2.0 done

* 16.2.1 done

* 16.2.2 done

* 16.2.3 done

* 16.2.4 done

* 16.2.5 done

* 16.2.6 done

* 16.2.7 done

* cleanup, py2 done

* remove old threading stubs

* use --strict-optional

* improve Condition.wait_for

* remove type ignore
2016-08-01 14:31:57 -07:00
Valérian Rousset
1bd78d4aab Improve contextlib (#406)
* remove old, new stubgen

* comment everything

* contextlib done

* use TypeVar instead of overload

* py2 done
2016-07-29 15:26:14 -07:00
Valérian Rousset
cfde32b93f Add mimetypes (#404)
* remove old mimetypes, new stubgen

* reorder, cleanup

* py3 pass (py2 pass empty)
2016-07-29 05:50:46 -07:00
Guido van Rossum
781b079f91 Add Supports{Abs,Float,Int,Round} as base classes for Decimal. (#415) 2016-07-28 15:13:27 -07:00
Alvaro Caceres
6701a10e93 Add 2.7/decimal.pyi generated by stubgen (#414)
* add decimaly.pyi

generated with
 stubgen --py2 decimal

* Strip out private stuff

* pytype compatibility

* fixes
2016-07-28 11:09:48 -07:00
Valérian Rousset
557579da36 merge py2 and py3 errno (#413) 2016-07-28 06:15:22 -07:00
johnklai1
112a1a17dd Add S_IRWXG to Python 2.7's stat.pyi file. (#409)
Fixes #408.
2016-07-27 11:29:12 -07:00
Valérian Rousset
cd413c502c Add hmac (#402) 2016-07-26 08:40:04 -07:00
Michael R. Crusoe
cc735b1176 expose xml.sax Exceptions (#280) 2016-07-26 07:45:27 -07:00