Commit Graph

1010 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
Yasushi Saito
61007ab1dc Add tm_zone and tm_gmtoff to time.pyi (#551)
* Enable tm_gmtoff and tm_zone only for python >= 3.3.
2016-09-19 14:38:14 -07:00
Sebastian Meßmer
93ef68315b Fixed types in stdlib/3/concurrent/futures: (#557)
* Fixed types in stdlib/3/concurrent/futures:
 - Remove private classes from public interface
 - Add missing types

* Remove "generated by stubgen" headers from modified type stubs

* - Use ... as default value
- Fix space formatting

* Replace more default values with '...'

* Use 'None' as default value where specified by documentation

* Use explicit Optional[T] type instead of default value None
2016-09-19 08:13:12 -07:00
Samuel Colvin
773ad48c04 correct utcoffset return type (#554) 2016-09-18 13:44:38 -07:00
Michael Lee
ec2b9ce97e Add partial stubs for fractions (#544)
This commit adds some incomplete stubs for the fractions module. In
particular, this commit does not add type signatures for the more
complex functions (such as `__add__`), and just leaves their types as
effectively `Any`.
2016-09-14 16:40:17 -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
Sebastian Meßmer
96ba62503b Use concrete type in sys.excepthook() (#547)
This is necessary, because exception formatting functions like `traceback.format_exception()` expect to get `Type[BaseException]`, but sys.excepthook only provided `type`
2016-09-14 08:03:41 -07:00
Elazar
e25b882041 Full signature for namedtuple (#541) 2016-09-13 16:17:26 -07:00
Guido van Rossum
08d1069d6b Since 2.6, the plistlib module is not Mac-specific. 2016-09-13 13:34:40 -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
Sebastian Meßmer
052574d821 Add missing type hints to subprocess.pyi (#539) 2016-09-13 09:17:17 -07:00
Guido van Rossum
0907e2cdda Add missing BytesIO.next(). 2016-09-12 12:24:06 -07:00
Sebastian Meßmer
f728e413b8 Fix a missing type in stat.pyi (#536) 2016-09-12 11:13:42 -07:00
Alvaro Caceres
ecc400f125 Make string.Template.substitute's arg optional (#535) 2016-09-12 11:12:28 -07:00
Alvaro Caceres
0321b2179b Declare logging.root -- undocumented but used. (#534) 2016-09-12 10:21:16 -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
Matthias Kramm
e70be5fbe2 trim pytype testing blacklist (#527) 2016-09-09 06:30:36 -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
Danny Weinberg
708fd960da Fix errors in stubs when running in strict mode (#515) 2016-09-02 19:04:56 -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
claws
35cdafa10e add some missing asyncio items such as gather (#511)
* add some missing asyncio items

* sort items
2016-08-31 07:28:22 -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
Elazar
59585bbf54 Update signature of ConfigParser.get() (#501)
Fix #492

Also add RawConfigParser
2016-08-29 12:44:30 -07:00
claws
bed8a60990 add hex to bytes, bytearray, memoryview (#507) 2016-08-29 09:39:35 -07:00
johnthagen
c0da198565 Add str into Union type for "ASCII to" functions which accept str. (#505)
Fixes #503
2016-08-28 13:48:24 -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
Elazar
f1047ec005 Stub: asyncore.pyi (#498)
* Stub: asyncore.pyi

I can't really test this stub since I don't use this module. I believe it's not far from the real thing.

It's based on the source code and not on the documentation.

https://hg.python.org/cpython/file/default/Lib/asyncore.py

* Option ->Optional

* add hint to count, remove addr

* make read/write explicit functions

* add synchat.pyi, move to 2and3

* change sys.version_info test

* try reversing the syntax
2016-08-26 13:34:42 -07:00
Danny Weinberg
68f8a278fe Improve correctness of pathlib stubs (#483)
I went through each method in the source and verified the inputs it accepts and outputs it gives. I also redefined a few methods on the `Path` class so that MyPy knows they return `Path` instead of `PurePath`. This is really just a temporary workaround until https://github.com/python/mypy/issues/1212 is fixed, but greatly improves the process of working with the `pathlib` module and is therefore likely worth the duplication.
2016-08-26 13:17:22 -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
Daniel F Moisset
0ffe3abf70 Adde JSON encoder and decoder objects (#499) 2016-08-25 08:33:39 -07:00
Guido van Rossum
73bdb705bf Delete ctypes. It is not yet ready for prime time, alas.
See https://github.com/python/typeshed/issues/475
2016-08-24 10:56:23 -07:00
peterdotran
ce940efc01 email.utils.parsedate and email.utils.parsedate_tz corrected to be passable to time.mktime (#497)
Also email.utils.parsedate_tz 10th element can be None if no timezone is specified
2016-08-24 06:10:56 -07:00
Elazar
e4b56b1be8 Stub for pyclbr.py (#487)
* Stub for pyclbr.pyi

* Quote opaque type with ""
2016-08-24 06:08:46 -07:00
Valérian Rousset
9f1e90b33f Merge bisect (#468)
* merge bisect

* comment while mypy#2035
2016-08-24 06:07:40 -07:00
Daniel F Moisset
fac745c90b Allow replace(tz_info=None) on time/datetime (#485)
* Allow replace(tz_info=None) on time/datetime

* Remove bool option for replace(tzinfo=...)
2016-08-24 06:05:21 -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
Michael Lee
c10198db11 Add the selectors module (#484)
* Correct some type errors

* Use Any instead of Optional[Any]
2016-08-23 18:57:46 -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
Antoine Catton
5b5135878b Typo: isis -> is (#495)
Fixes inspect.isgeneratorfunction().
2016-08-23 16:24:16 -07:00
Tomasz Elendt
9451fa922c Add start and stop arguments to Sequence.index in Py >= 3.5 (#489)
Fixes #486.
2016-08-22 14:53:48 -07:00
David Euresti
ff86b1bd26 Remove empty wintypes module which just causes imports to break (#490) 2016-08-22 08:48:33 -07:00