Commit Graph

517 Commits

Author SHA1 Message Date
Sebastian Rittau
efb4af0108 Mark some types as non-hashable (#3219)
Based on @JelleZijlstra's PR #2221.

Fixes #2148
2019-09-04 17:38:09 +02:00
Pascal Corpet
b94fa842eb Type response of Flask test client methods: get, post, etc. (#2904) 2019-09-03 11:12:11 +02:00
Shannon Zhu
f9300ed1ed Update pyre_extensions stub (#3214) 2019-08-30 16:15:24 -07:00
Colin Gilgenbach
99e8ed42a4 Mark ParamType.fail() as NoReturn (#3213)
This function just raises a click.BadParameter exception with the supplied arguments.
2019-08-29 17:57:43 +02:00
Sebastian Rittau
ae881faaf1 Remove custom _Text type (#3211)
* Remove custom _Text type

Since the custom type was only used in argument types, it was
effectively only an alias for typing.Text.

* Run requests/api.pyi through black
2019-08-29 08:51:59 -07:00
Benjamin Peterson
f53f52de57 requests: Allow bytes for url parameters. (#3209)
typeshed already partially reflected https://github.com/psf/requests/pull/2238 but not completely.
2019-08-28 21:53:19 -07:00
Benjamin Peterson
a48abb4546 Add unquote_to_bytes to Python 3 six.moves.urllib.parse. (#3208) 2019-08-28 18:01:38 -07:00
Shannon Zhu
72010bc5dc Update how mock classes alias to Any (#3182)
* Update how mock classes alias to Any

> First, the z: Any situation looks like a bug or accidental feature to me.
This is definitely meant (and works) as a variable declaration; that it
also allows using z as a type seems wrong. I can't find any evidence in
PEP 484 that this was intended; in mypy it's likely the accidental result
of other design choices meant to shut up errors about Any.

Ideally these classes could be declared as empty class stubs, but since the comments suggest this isn't possible yet, let's update these to be type aliases to Any rather than global variables of type Any. This would avoid invalid type errors when the implementation of type checkers respect the intention that `z: Any` does not make `z` a valid type.

* Update mock.pyi
2019-08-19 17:10:27 -07:00
Bouteillebleu
d5a918de7b Add stubs for CGIHTTPServer (#3196)
This commit adds:
* Stubs for CGIHTTPServer in the Python 2 standard library, as requested in #1147.
* Stubs for six.moves.CGIHTTPServer in Python 2, as requested in #22.
2019-08-19 15:34:29 +02:00
Rebecca Chen
fab2ee0d7c Remove unnecessary quotes around forward references. (#3191) 2019-08-16 20:29:32 -07:00
Michael Lee
b294782183 Make most contextmanager __exit__ signatures return Optional[bool] (#3179)
This pull request is a follow-up to https://github.com/python/mypy/issues/7214.

In short, within that mypy issue, we found it would be helpful to
determine between contextmanagers that can "swallow" exceptions vs ones
that can't. This helps prevent some false positive when using flags that
analyze control flow such as `--warn-unreachable`. To do this,
Jelle proposed assuming that only contextmanagers where the `__exit__`
returns `bool` are assumed to swallow exceptions.

This unfortunately required the following typeshed changes:

1. The typing.IO, threading.Lock, and concurrent.futures.Executor
   were all modified so `__exit__` returns `Optional[None]` instead
   of None -- along with all of their subclasses.

   I believe these three types are meant to be subclassed, so I felt
   picking the more general type was correct.

2. There were also a few concrete types (e.g. see socketserver,
   subprocess, ftplib...) that I modified to return `None` -- I checked
   the source code, and these all seem to return None (and don't appear
   to be meant to be subclassable).

3. contextlib.suppress was changed to return bool. I also double-checked
   the unittest modules and modified a subset of those contextmanagers,
   leaving ones like `_AssertRaisesContext` alone.
2019-08-16 16:13:33 -07:00
Patrick Valsecchi
26f575130c Add some redis types (#3092) 2019-08-10 13:22:40 -07:00
Benjamin Peterson
0dc3bf941a Improve type of tornado.testing.gen_test. (#3174)
gen_test can accept a timeout parameter. See https://www.tornadoweb.org/en/branch5.1/testing.html#tornado.testing.gen_test.
2019-08-10 13:08:59 -07:00
Sebastian Rittau
628eee29f7 Use Literal in a few more places (#3176) 2019-08-10 13:08:18 -07:00
Sebastian Rittau
c579f91077 Improve werkzeug exceptions slightly (#3178)
* Use Text for HTTPException.description
* Add Unauthorized.www_authenticate
* Remove wrong get_headers() overrides
2019-08-09 20:05:56 +02:00
g.denis
50f1988650 concurrent: add private classes and exceptions (#3169) 2019-08-07 10:39:15 +02:00
Ilya Konstantinov
4c8d577d68 flask: allow view func body to be dict (#3149) 2019-07-31 02:04:36 +02:00
Allison Kaptur
15aa18d0a2 dateutil.rrule can take dates (#3154) 2019-07-27 11:39:23 +02:00
Sebastian Rittau
9ccf9356bf Remove Python 3.4 support (#3147)
Closes #3123
2019-07-27 10:58:21 +02:00
Sebastian Rittau
0177dedc42 Add werkzeug.middleware (#3103)
HTTPConnection.timeout can be a float
2019-07-24 08:51:55 -07:00
Nipunn Koorapati
67d091db15 Update google RepeatedCompositeFieldContainer (#3136) 2019-07-22 09:00:22 +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
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
Francis Colas
75d9228b02 PurePath methods accept os.PathLike[str] from 3.6 (#3099)
Closes #3095
2019-07-02 13:08:32 +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
Gordon Ball
7e9e91cb7b Restore default value to click.echo_via_pager (#3090) 2019-06-26 13:21:05 -07: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
crusaderky
9941616b9e Add mp_context parameter to concurrent.futures.ProcessPoolExecutor (#3078)
Closes #3076
2019-06-20 19:42:26 +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
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
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
Anthony Sottile
ed2a851ed8 dateutil: byweekday can take weekday (#3046) 2019-06-10 11:21:50 -07:00
Connor Skees
55a566340a Add copy() method to requests.Session.headers (#3043)
* Add `copy()` method to requests.Session.headers

* Use one type annotation
2019-06-08 12:19:57 -07:00
markedwards
5c94b58752 Add FullLoader and FullConstructor classes to yaml (#3035) 2019-06-06 17:47:39 +02:00
Evan Moses
db5fc492aa Added tojson_filter and detect_encoding to flask.json (#3030) 2019-06-05 23:39:49 +02:00
Chandan Singh
233f2abf19 click: Use property decorator for read-only properties (#3028)
Since these properties do not have a setter, be explicit with the
`@property` decorator. This will allow type checkers to see that
assignment of these attributes is an error.

See https://github.com/python/typeshed/pull/3027#discussion_r289623016
for some related context.
2019-06-03 08:13:52 -07:00
Chandan Singh
018ecb3f16 Update Click to 7.0 (#3027)
Closes #3020.
2019-06-03 07:38:27 -07:00
Mathieu Bridon
6061ca404e Move Redis stubs to 2and3 (#3015)
They actually work for both Python 2 and 3, mostly because they aren't
really typed yet.
2019-05-29 15:45:46 +02:00
Mark Mendoza
d8e14d6ead [pyre] Adding IntVar to typing_extensions (#3008) 2019-05-28 19:48:13 +02:00
Ran Benita
45266c9c32 Allow is_dst=None in pytz.BaseTzInfo.localize() (#3002)
See http://pytz.sourceforge.net/#problems-with-localtime
2019-05-21 10:16:30 +02:00
Jukka Lehtosalo
e3773ad691 Fix typos in yaml stubs (save_* -> safe_*) (#2985) 2019-05-13 11:57:34 -04:00
Simon Kohlmeyer
a868221347 Update dateutil to 2.7.5 (#2694)
This is still missing the easter and tzinfo module, but includes newer
functions like today and isoparse.
2019-05-13 07:58:43 -07:00
Jean Hominal
897148073a Add functions to six.moves.urllib.request (#2982)
parse_http_list and parse_keqv_list were added to six.moves.urllib.request
in version 1.11.
2019-05-13 10:29:34 +02:00
Rebecca Chen
aa4a84ef3f Always use fully qualified names to refer to nested classes. (#2983)
The main purpose of this change is to get the stubs into a
form that pytype will support with its next release. Since
these stubs already mostly use fully qualified names, this
will also increase consistency.
2019-05-12 15:10:48 -07:00
Danny Weinberg
b4376fc3d2 Have click.style return a str (#2981)
This previously was missing a return type and therefore defaulting to
`Any`, but it actually returns a `str`.
2019-05-11 22:20:31 +02:00
zadamah
c03100230d Add new show_choices argument to click options (#2978) 2019-05-09 16:28:08 +02:00
Ivan Levkivskyi
d61635e243 Add TypedDict to typing_extensions (#2940)
Since there is a PEP for `TypedDict` (PEP 589), it is being added to `typing_extension`, see https://github.com/python/typing/pull/628. This PR essentially copies the definition from `mypy_extensions`.

Corresponding mypy PR https://github.com/python/mypy/pull/6744 can be merged independently of this PR.
2019-05-07 14:45:45 -04:00