Commit Graph

2718 Commits

Author SHA1 Message Date
Sebastian Rittau
09d1055cd3 Remove mypy new analyzer tests (#3128)
Now that the new analyzer is the default, this does exactly the same
as the normal mypy self test.
2019-07-18 17:02:12 +02:00
Ivan Levkivskyi
508f992730 Add __eq__ to protobuf containers (#3126)
See https://github.com/protocolbuffers/protobuf/blob/master/python/google/protobuf/internal/containers.py.

Without these `mypy --strict-equality` causes false positives with protobufs.
2019-07-17 23:25:22 +01:00
William Ayd
8e89faa90f Added Optional (#3125)
Fixes #3124
2019-07-17 10:08:46 +02:00
Michael J. Sullivan
3ad3ed82c7 Overload the constructor of subprocess.Popen (#3113)
This takes advantage of a recent mypy change to respect the return
type of `__new__`. Using that it does the same tedious overloads
as `run` and `check_output`.
2019-07-16 15:41:33 -07:00
秋葉
e2ec5d0525 Make SyntaxError.text be optional (#3119)
Closes #3118
2019-07-15 09:11:45 +02:00
Anthony Sottile
f76b7b273b Re-export _curses._CursesWindow from curses (#3117) 2019-07-13 08:01:10 -07:00
Anthony Sottile
2a57ce2cec Add curses.COLORS and curses.COLOR_PAIRS (#3115) 2019-07-13 07:50:13 -07:00
Rebecca Chen
40124b5f4c Update required pytype version to one that supports async def. (#3112) 2019-07-11 12:47:46 -07:00
Brandt Bucher
34b47101dd Slice attributes can be of any type. (#3024) 2019-07-11 12:13:32 -07:00
Ran Benita
4ae4714e00 sys: refine the return type of sys.exc_info() (#3111) 2019-07-11 10:43:37 +02:00
Michael J. Sullivan
b43e1d674f Use Literal overloads to give better types to subprocess (#3110)
This gives better types to `subprocess.check_output` and `subprocess.run`
by laboriously overloading using literals.

To support `run`, I turned `CompletedProcess` into `_CompletedProcess[T]`
with `CompletedProcess = _CompletedProcess[Any]`. I could pretty easily
be convinced that it would be better to just make `CompletedProcess`
generic, though.

I'd like to do the same for Popen but need to make mypy support
believing the type of `__new__` in order for that to work.
2019-07-10 14:44:27 -07:00
Cole Maclean
f5c107cacd BytesGenerator requires BinaryIO (#3106) 2019-07-07 22:03:07 -07:00
Sebastian Rittau
1436cfdef9 Add types to FileStorage (#3067) 2019-07-04 12:58:51 -07:00
Savo Kovačević
84e6492d7e Improving Flask stubs (#3003)
* Fix flask render_template and render_template_string stubs

* Add types for flask view function

* Import TracebackType from the right location

* Switch to bound typevar in route decorator stub

* Change render_template and render_template_string parameters to Text
2019-07-04 12:57:06 -07:00
Sam Zhou
4af283e1ac Fix HTTPConnection.putrequest parameter names (#3101) 2019-07-03 08:52:59 +02:00
ikelos
3e700224ba Add in multiprocessing.managers.ValueProxy types (#3100)
Fixes #1778
2019-07-03 08:49:16 +02:00
Francis Colas
75d9228b02 PurePath methods accept os.PathLike[str] from 3.6 (#3099)
Closes #3095
2019-07-02 13:08:32 +02:00
Rafi Blecher
668d050476 Fix contextlib GeneratorContextManager name for py>=3.2 (#3083) 2019-07-02 10:56:40 +01:00
Martijn Pieters
e1e5c83795 QueueHandler / QueueListener accept SimpleQueue too (#3098)
The implementation of `logging.adapters.QueueHandler` and `logging.adapters.QueueListener` works great with `queue.SimpleQueue` too, so update the stub to reflect this.

The new queue.SimpleQueue class (introduced in 3.7) is faster but is not a Queue subclass as it doesn't implement task handling (`handle_task()` / `join()`) or queue bounds (raising `queue.Full` / `full()`). The logging handler / listener implementations do not make use of those features however.

Related Python bug, asking for an explicit documentation mention: https://bugs.python.org/issue37469
2019-07-01 07:47:30 -07:00
Ran Benita
c66699800e xml.etree.ElementTree: fix missing None in get(), findtext() return type (#3093) 2019-07-01 14:28:40 +02:00
Jason Gilholme
8b66e08745 Add Generic Typing to Queue.PriorityQueue and Queue.LifoQueue in python 2 (#3036) 2019-07-01 14:05:13 +02:00
Hynek Schlawack
47450629c9 Add TLSVersion & related attributes to SSLContext (#3097) 2019-07-01 14:03:57 +02:00
Benjamin Woodruff
3272307933 Make dataclasses.Field.metadata non-optional (#3094)
If `metadata` is `None` the Field constructor replaces it with an empty
mapping object, so this value can never be None.

https://github.com/python/cpython/blob/v3.7.3/Lib/dataclasses.py#L243
2019-06-28 18:28:50 -07:00
Rebecca Chen
5dc89fe8cf Add undocumented methods codecs.utf_16_be_{decode,encode}. (#3091)
I found the signatures here:
6a16b18224/Modules/_codecsmodule.c (L729)

https://github.com/google/pytype/issues/348 was opened against
pytype about utf_16_be_encode being missing.
2019-06-26 20:29:16 -07:00
Gordon Ball
7e9e91cb7b Restore default value to click.echo_via_pager (#3090) 2019-06-26 13:21:05 -07:00
Eric Arellano
8131bfc3f6 Install Black and isort autoformatters (#3069)
* Install Black and isort

* Add config via pyproject.toml

Notably we keep the convention of 130 line length.

* Add target python version
2019-06-24 08:44:20 +02:00
redshiftzero
64b12bf7f1 itsdangerous: update JSONWebSignatureSerializer.dumps return type (#3082)
On Python 2, a str is returned, however on Python 3 the return type
is bytes.
2019-06-22 14:15:37 -07:00
Chad Dombrova
e25c0cb128 "key" argument of builtin function sorted should be optional in python 2.7 (#3086) 2019-06-22 14:09:51 -07:00
Maarten ter Huurne
bdd49d0f3a Fix annotation of re.Match 'lastindex' and 'lastgroup' in Python 3 (#3085)
Both are None if there were no groups matched. Also 'lastgroup'
will be None if the matched group was nameless.

The Python 2 versions of these annotations already used Optional.
2019-06-22 10:18:16 -07:00
Jelle Zijlstra
b0c9fa4530 fix type of loop.sock_connect (#3073) 2019-06-21 17:31:51 +02:00
Jelle Zijlstra
ada0570efc Revert "Define functools.partial as overloaded function instead of its own class (#2878)" (#3077)
This reverts commit e45f443d85.
2019-06-20 20:39:49 -07:00
crusaderky
9941616b9e Add mp_context parameter to concurrent.futures.ProcessPoolExecutor (#3078)
Closes #3076
2019-06-20 19:42:26 +02:00
秋葉
2b6a99c39c fix ssl.Purpose type in py3 (#3054) 2019-06-20 19:41:32 +02:00
Rune Tynan
58221cf20e Add types and functions in types.py that are new in 3.7 (#3066)
* Add types and functions in types.py that are new in 3.7

* Update `resolve_bases` to accept any iterable of objects, and the same
for `new_class` if the version is at least 3.7

* Add comparison overrides implemented by MethodWrapperType

* Fix mypy error due to over-constrained `__eq__`
2019-06-19 15:20:57 -07:00
Eric Arellano
1763f51c0d Refactor tests/pytype_test.py (#3065) 2019-06-19 15:19:10 -07:00
Florian Ludwig
2e10326b50 change http.cookies.Morsel to Dict[str, Any] (#3060)
Morsel does cast any value to string and therfor any is the correct
typehint. For some keys other types then strings are more
appropiate anyway, max-age can take an integer (unix time) and http-only
a boolean.

Closes #3059
2019-06-19 15:17:16 -07:00
Matthew Wilkes
d149fe435c Represent the use of IntEnums in functions in socket.py. (#3009)
The Pull Request #1121 added the `AddressFamily` type to `socket.pyi`
for Python 3.4+, so constants such as `AF_INET` are correctly
represented as being an enum member rather than an int. The same is
true of the `SocketKind` enums in the `SOCK_*` family.

Various functions in the socket module can accept either an int
or an `AF_*` enum member as arguments, which is allowed by the
int argument type. However the `getaddrinfo` function returns an
`AddressFamily` member rather than an int in the first position
of its list members, so code that access enum specific members
such as the `name` attribute causes a typing error to be found.

This change corrects the return type of `getaddrinfo` but leaves
the family parameters as int, given that `AddressFamily` members
are `IntEnum` and only ever treated as `int`s internally.
2019-06-19 15:14:15 -07:00
Motoki Naruse
aa56af7dce HTMLParser.get_starttag_text() can return None (#3072) 2019-06-19 15:34:37 +02:00
Mathieu Bridon
38f253ed69 redis: Add some type hints (#3055) 2019-06-18 18:19:51 +02:00
Ivan Levkivskyi
01c2fa5a14 Sync recent typing and typing_extensions updates (#3070)
This includes two things to sync up with recent runtime updates:
* Move `Final`, `@final`, `Literal`, and `TypedDict` to `typing` (`typing_extensions` still defines or re-exports them)
* Rename `@typing.runtime` to `@typing.runtime_checkable`, while keeping `@runtime` as a backwards-compatible alias in `typing_extensions`.
2019-06-18 02:31:54 +01:00
Carl Meyer
fcb97fe8f1 Overload ast.parse to recognize that mode=exec means Module return. (#3039) 2019-06-17 23:27:14 +02:00
Jadiker
5447ff6bfe str and unicode format functions take objects (#3068) 2019-06-17 20:09:11 +02:00
Alexander Fasching
6258e7ddfd ssl.pyi: fix types of cadata argument (#3063) 2019-06-16 14:11:10 -07:00
Sean Vig
1efebf78e4 Marshal dumps/loads uses bytes (#3061)
The marshal.dumps and marshal.loads functions should return and accept
bytes, respectively, rather than a string.
2019-06-16 16:17:26 +02:00
Eric Arellano
d36a519b95 Update select and selectors to use _HasFileno protocol (#3057) 2019-06-15 16:35:18 -07:00
Mark Mendoza
1f740a7926 Adding stubs for pyre_extensions (#3056) 2019-06-13 23:14:54 +02:00
Joe Juzl
8ffe20fc22 Add redis stream methods to the client stubs (#3051) 2019-06-13 09:24:39 -07:00
Utkarsh Gupta
8e7c32846f request.pyi: Change Union[] -> Any for attributing status. (#3045)
Fixes #3026
2019-06-13 12:01:13 +02:00
John Freeman
e4a9cd580c Add missing path-like annotation (#3053)
Fixes #3052
2019-06-12 20:03:14 +02:00
Sebastian Rittau
b9101e9c5e Add a few Redis types (#3016)
* StrictRedis is an alias for Redis in current redis

* Add a few types

* Add missing import

* Add missing argument and types
2019-06-12 09:18:48 -07:00