Commit Graph

2017 Commits

Author SHA1 Message Date
Jelle Zijlstra
8482b1030b fill out stubs for requests.structures (#1897)
Looked at https://github.com/requests/requests/blob/master/requests/structures.py.

The "data" argument to the CaseInsensitiveDict constructor is passed as is to .update(),
so I accept the same argument types as MutableMapping.update.

LookupDict is strangely named and implemented but the point seems to be that you
setattr its keys, and then can access them with both attribute access and subscripting.
See its usage in d1fb1a29ab/requests/status_codes.py (L102).
2018-04-06 11:36:43 -07:00
Jelle Zijlstra
482f207b3c os.fwalk supports bytes (#2013)
python/cpython@8f6b344 and https://bugs.python.org/issue28682.

I could not use the _PathLike alias because that includes bytes.

Part of #1965.
2018-04-06 11:22:15 -07:00
Jelle Zijlstra
d24799fd31 uncomment a few parts of six.moves (#2019) 2018-04-06 11:20:14 -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
54ecefef04 removals in Python 3.7 (#2018)
Last part of #1965.
2018-04-06 11:11:29 -07:00
Jelle Zijlstra
0acdfd1548 more 3.7 features (#2017) 2018-04-06 11:09:45 -07:00
Jelle Zijlstra
7cfbc7d17f more 3.7 features (#2015) 2018-04-06 11:09:11 -07:00
Jelle Zijlstra
ce0656a8c7 add some more Python 3.7 features (#2014) 2018-04-06 11:08:30 -07:00
Omar Sandoval
32b4eacea1 Add missing exitmsg argument to code.interact() (#2024)
According to https://docs.python.org/3/library/code.html#code.interact,
this was added in Python 3.6.
2018-04-06 07:02:58 -07:00
Danny Weinberg
12d60a2760 Allow passing None for gflags default string value (#2016) 2018-04-04 16:50:28 -07:00
Christopher Schramm
7f34bbcb88 Add pkgutil.ModuleInfo (#2010) 2018-04-04 15:15:43 -07:00
Jelle Zijlstra
0af84cd9a0 upgrade flake8, pin flake8-pyi version (#2001)
I'd prefer to pin the exact flake8-pyi version so that test runs are more reproducible.
2018-04-03 07:16:34 -07:00
Alan Du
603be5e1da Fix typehint of click progressbar (#2003)
* Fix typehint of click progressbar

* Oops -- stubs are *.pyi files
2018-04-03 07:16:17 -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
Matt Gilson
8e3182dafa dict.fromkeys supports arbitrary iterables. (#2012)
This should fix #1529.
2018-04-03 07:12:04 -07:00
Michael J. Sullivan
df55343e60 Fix some more ctypes issues (#2009)
* Make {C,WIN,PY}FUNCTYPE's restype argument optional (for void returns)
 * Make WinError return WindowsError
 * Don't have Array explicitly inherit from Sized
   (since inheriting from classes with different metaclasses causes problems, 
    and it is a protocol anyways)
 * Have Array.__iter__ properly return an Iterator instead of an Iterable
2018-03-30 18:03:52 -07:00
Michael J. Sullivan
9b99161ca9 Make argtypes in ctypes be a Sequence instead of a Tuple (#2005)
A lot of code uses lists here.
2018-03-29 14:55:56 -07:00
dgelessus
06aee52581 Fix some issues in ctypes (fixes #1983) (#1986)
* Support additional argument types for c_void_p parameters
* Don't allow passing bytes where a writable c_void_p is expected
* Fix type of ctypes._CDataMeta.__[r]mul__
* Rename ctypes._cparam to _CArgObject to match the real type name
* Fix value type of ctypes.HRESULT
* Add stub for ctypes.wintypes
* Fix trailing whitespace in ctypes.wintypes
* Add a workaround to ctypes.Array to fix incorrect typing in some cases
* Expand multiple assignments so mypy recognizes them as type aliases
* Rename ctypes._Pointer to pointer so it can be used externally
2018-03-29 12:41:42 -07:00
Bryce Guinta
f42724444f Update math stub arguments to reflect protocol support (#2002)
Update math.factorial to reflect support for __int__ protocol.
Update other math functions to reflect support for __float__
protocol.
2018-03-29 07:59:27 -07:00
Jelle Zijlstra
43e6c3c435 add more minor 3.7 new features (#2000)
part of #1965
2018-03-28 21:28:27 -07:00
Łukasz Langa
6a1d25b73e Document why E741 is ignored 2018-03-28 20:25:50 -07:00
Jelle Zijlstra
26e573ba1c change default value to ... in inspect.pyi (#1998)
This is in our style guide. This is the last piece of offending code; I just submitted ambv/flake8-pyi#10 to enforce the rule in the linter in the future.
2018-03-28 20:24:39 -07:00
Jelle Zijlstra
5201ccdfff add E741 to ignored flake8 codes (#1999)
This was introduced in a recent version (so it doesn't affect us right now but will if we upgrade the flake8 version used in tests). It gives errors like:
```
/home/travis/build/ambv/flake8-pyi/.tox/typeshed/tmp/typeshed/stdlib/3/re.pyi:21:9: E741 ambiguous variable name 'I'
/home/travis/build/ambv/flake8-pyi/.tox/typeshed/tmp/typeshed/stdlib/3/re.pyi:39:5: E741 ambiguous variable name 'I'
/home/travis/build/ambv/flake8-pyi/.tox/typeshed/tmp/typeshed/stdlib/3/re.pyi:58:5: E741 ambiguous variable name 'I'
/home/travis/build/ambv/flake8-pyi/.tox/typeshed/tmp/typeshed/third_party/2/OpenSSL/crypto.pyi:43:5: E741 ambiguous variable name 'O'
```
These aren't useful for typeshed, because regardless of whether it's good style, these libraries really do contain variables named `I` and `O`.
2018-03-28 20:24:24 -07:00
Jelle Zijlstra
371b805c23 improve selenium stubs (#1732) 2018-03-28 19:39:43 -07:00
Jelle Zijlstra
0c15e5bdcc Improve werkzeug stubs (#1730) 2018-03-28 19:38:35 -07:00
Evan Krall
4563c5a1ac ArgumentParser's add_argument returns the Action that was created. (#1881)
* ArgumentParser's add_argument returns the Action that was created.

* Make add_argument's dest parameter Optional. _ArgumentGroup's add_argument should also return the Action.
2018-03-28 19:09:22 -07:00
Sebastian Rittau
0170e6d3c7 traceback.print_exception(): Arguments optional in Python 3 (#1982) 2018-03-28 18:45:14 -07:00
Jelle Zijlstra
200273edeb add stub for importlib.resources (#1993)
Part of #1965
2018-03-28 18:44:40 -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
Russell Cloran
a62c6be905 Make encoding and newline optional in tempfile (#1995)
`encoding` and `newline` have a default value of `None` in stdlib, for all of
the classes/functions that take these parameters.
2018-03-28 16:41:24 -07:00
Patrick Meyer
6c09e19847 Add missing attribute socket to asyncore (#1991)
* Add missing attribute socket to asyncore

* Mark asyncore.dispatcher.socket as optional and undocumented
2018-03-28 10:08:44 -07:00
Eric Wieser
6cf1ec9654 Mark all dunder attributes of BaseException as Optional (#1992)
All of these properties can be set to `None`.

Also updates `with_traceback` to only accept the values which can be stored in `__traceback__`
2018-03-28 07:55:10 -07:00
Semyon Proshev
ac70fdc614 Overloads for map (#1990) 2018-03-27 10:05:59 -07:00
Semyon Proshev
8ac7f68a86 Update return type for math.ceil in Python 2 (#1989) 2018-03-27 08:09:18 -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
João Santos
afeecb478b RotatingFileHandler has a terminator property (#1952)
In python3 `RotatingFileHandler` is a subclass of `BaseRotatingHandler` which is a subclass of `FileHandler` which is a subclass of `StreamHandler` which as a `terminator` property but I'm getting a `"RotatingFileHandler" has no attribute "terminator"` error on my code.
2018-03-25 08:11:01 -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
Michael J. Sullivan
eb571e9cbb Make protobuf's BaseContainer a MutableSequence (#1981) 2018-03-22 18:22:59 -07:00
David Euresti
097e9f5e71 Fix issue with attrib ordering. (#1980)
A call like this:

```
from attr import attrib
from attr.validators import optional, instance_of

c = attrib(default=None, validator=optional(instance_of(bytes)))
```

Was returning no return value, because the first overload was T -> T.
The solution was to change the ordering so that the first overload is
None -> T and infer the type from the other arguments.
2018-03-22 10:50:07 -07:00
Jelle Zijlstra
bbbffb5f4b implement some minor 3.7 features (#1966)
References:
- https://docs.python.org/dev/library/datetime.html#datetime.datetime.fromisoformat
- https://docs.python.org/dev/library/crypt.html#crypt.mksalt
- https://docs.python.org/dev/library/contextlib.html#contextlib.AbstractAsyncContextManager
- https://docs.python.org/dev/library/calendar.html#calendar.HTMLCalendar.cssclasses
- https://docs.python.org/dev/library/binascii.html#binascii.b2a_uu

Part of #1965.
2018-03-22 08:01:09 -07:00
matthewfranglen
9a6a7a2e75 See #1977: Delete DoneAndNotDoneFutures definition (#1978)
The generic type of the futures provided to the wait method cannot
currently be preserved through this definition. For now deleting the
unused NamedTuple is the best approach.
2018-03-22 07:59:13 -07:00
Jelle Zijlstra
b9c5e811df allow instantiating TracebackType in 3.7 (#1967)
See https://docs.python.org/dev/reference/datamodel.html#traceback-objects
and python/cpython#4793.

part of #1965
2018-03-21 15:26:23 -07:00
Jelle Zijlstra
bfe0b06953 add stub for contextvars.pyi (#1968)
Part of #1965.
2018-03-21 15:16:14 -07:00
Luka Sterbic
89cbd47344 Stubs for termcolor (#1935) 2018-03-20 15:32:50 -07:00
Leonardo Fedalto
a9cce0c94b Add requests.utils.set_environ (#1973) 2018-03-20 11:15:52 -07:00
Josh Holland
162d884d32 Make zipfile accept Text, not str (#1826) 2018-03-17 22:33:29 -07:00
Ashwini Chaudhary
164aa21fa1 Added stub for dircache(py2) (#1510) 2018-03-17 22:22:25 -07:00
Nipunn Koorapati
cac7264d3a Add google.protobuf.internal.containers.pyi to typeshed (#1718) 2018-03-17 22:05:43 -07:00
z33ky
c2c48424da Add missing collections.defaultdict.__init__ overloads (#1957) (#1958) 2018-03-17 08:22:11 -07:00
dgelessus
8009a34b90 Re-add stubs for ctypes (#1906)
* Convert type comments to variable annotations in ctypes.__init__

* Add missing List import in ctypes.__init__

* Add missing bound kwarg to _CT TypeVar in ctypes.__init__

* Fix ctypes._CData classmethod definitions

* Fix ctypes Structure/Union __getattr__ definitions

Both Structure's metaclass and Structure itself define a __getattr__.
The former returns field objects (each representing a field definition
in the Structure), while the latter can return anything (the value of
the field in a specific Structure instance).
Structure also defines a __setattr__, while Structure's metaclass
does not.

BigEndianStructure, LittleEndianStructure and Union support the same
operations as Structure does, but the semantics obviously differ.

Depending on the system endianness, exactly one of the EndianStructures
is an alias for Structure, and the other one is a special Structure
subclass. For simplicity, both EndianStructures are considered
subclasses of Structure here, even though this is technically not
always accurate.

* Fix swapped parameter types in ctypes._CData.in_dll

* Add limited support for ctypes._CData.__class__.__mul__

It's not possible to specify the correct return type for __mul__ and
__rmul__ here - see comments for explanation.

* Make ctypes._FuncPtr extend ctypes._CData

* Improve typing of ctypes.cast

* Mark class attributes with ClassVar in ctypes.__init__

* Mark ctypes._CData.from_buffer[_copy] offset arg as optional

* Remove trailing whitespace in ctypes.__init__

* Don't export ctypes.UnionT

* Add ctypes._DLL.__getitem__

* Make ctypes._DLL.__get(attr|item)__ return _FuncPtr instead of Any

* Change ctypes DLL inheritance hierarchy to match the real one better

* Add some missing attributes to ctypes.CDLL

* Rename ctypes._FuncPtr so it doesn't conflict with CDLL._FuncPtr

* Fix type of ctypes.CDLL._FuncPtr

* Merge _FuncProto into _FuncPointer

The function pointer types returned by CFUNCTYPE and friends are the
same as those encountered elsewhere, so there's no need to treat them
differently.

* Fix some leftover references to ctypes._DLL

* Simplify definition of ctypes._DLLT

* Add ctypes.LibraryLoader.__get(attr|item)__

* Use Text instead of str where appropriate in ctypes.__init__

* Make ctypes.c_char accept ints

* Make ctypes.c_[w]char_p accept None

* Remove unneeded Generic base from ctypes.py_object

* Make ctypes.cast accept _cparam

* Fix ctypes._PF being declared too late

* Remove incorrect ctypes.PyDLL.__init__ override
2018-03-16 20:17:24 -07:00