Commit Graph
148 Commits
Author SHA1 Message Date
Amol BhaveandJelle Zijlstra 8000513868 Change return type for click.Context.fail and click.Context.abort to NoReturn (#2326) 2018-07-11 20:16:55 -07:00
Amol BhaveandJelle Zijlstra 66e9aa644b Fix type for click.Context.exit (#2325)
click.Context.exit() calls sys.exit() and hence should be a NoReturn return type.
2018-07-11 19:58:18 -07:00
David EurestiandJelle Zijlstra 2899d0a6aa Make click decorators not modify the type (#2322) 2018-07-11 12:35:05 -07:00
Ran BenitaandJelle Zijlstra cadacab088 Add missing attributes to the dateutil/relativedelta stub (#2319)
I have deduced the types from docstring & source code of the
relativedelta class.

Fixes #2269.
2018-07-10 08:08:39 -07:00
Bertrand Bonnefoy-ClaudetandJelle Zijlstra f582b53ff7 Add stub file for click.testing (#2243)
Click already had stubs but not for the `testing` submodule.

I used stubgen and then narrowed the types when it was easy.  I left
`Any` where more work was necessary.
2018-07-05 20:40:48 -07:00
Yusuke MiyazakiandJelle Zijlstra 6192cce9d9 Avoid using string literals in type annotations (#2294) 2018-07-02 20:23:29 -07:00
Yusuke MiyazakiandJelle Zijlstra 581705d9ee Prefer to use ellipsis over pass (#2292) 2018-06-28 10:29:45 -07:00
potykionandJelle Zijlstra f35c5d1349 Jinja2 async support (#2278) 2018-06-28 10:24:37 -07:00
Nipunn KoorapatiandGuido van Rossum b7df5a670a Add type stubs for google.protobuf.service (#2187) 2018-06-27 15:38:29 -07:00
Ethan SmithandJelle Zijlstra de1755b263 Remove type cycle in click (#2277) 2018-06-26 07:24:55 -07:00
Guido van RossumandJelle Zijlstra 41e5fe4457 Message.WhichOneof returns Text, not bytes (#2274) 2018-06-23 15:42:13 -07:00
Jukka LehtosaloandIvan Levkivskyi 07374a8251 Fix requests.post signature (#2256)
The change introduced in 395ab5abd1
broke the signature of `requests.post`, among others, since
`MutableSequence` is invariant, and plain `Dict[str, str]` values
were no longer valid for the `data` argument.

This changes the signature to have `Any` components as a
compromise. Adding more items to the union seems a bit too much, since
the error messages for invalid argument types are already pretty hard to
read.

Another option might be to use `Mapping` instead of `MutableMapping`
due to covariance, but I assume there's a reason why `MutableMapping`
is used here.
2018-06-19 17:08:55 +01:00
Jukka LehtosaloandGitHub feeb4e71ef Change mock classes to Any values to avoid false positives (#2255)
The previous definitions in `mock` caused many false positives in
internal Dropbox repositories.

One source of problems was `List[Mock]` not being compatible with
`List[SomeClass]`, since `list` is invariant.
2018-06-19 16:28:19 +01:00
Jukka LehtosaloandIvan Levkivskyi a88d942f91 Add missing protobuf container methods (#2254)
Implementation of the methods is here:

https://github.com/google/protobuf/blob/master/python/google/protobuf/internal/containers.py
2018-06-19 15:52:54 +01:00
Jelle ZijlstraandGitHub 94ab32ba59 Fix abstract classes for Python 3 (#2239)
* add metaclass=ABCMeta to some classes

* mark some more classes as explicitly abstract

* make some more classes concrete
2018-06-16 10:18:54 -07:00
Anthony SottileandJelle Zijlstra 395ab5abd1 Values of data are Optional (#2231) 2018-06-15 07:48:55 -07:00
Bertrand Bonnefoy-ClaudetandJelle Zijlstra 4b5a63d10f Fix werkzeug.wrappers.BaseResponse.__init__ (#2232)
This additionally allows strings, bytearrays and string iterables to be
passed as the `response` argument of `BaseResponse` (and thus also
`Response`).

Strings and bytearrays are explicitly handled in `__init__` [1].
Strings are also featured on the Werkzeug front-page snippet (`'Hello
World!'`) [2].

[1]: https://github.com/pallets/werkzeug/blob/d129d17066768238139b8f8a5d667d9a4f4d68db/werkzeug/wrappers.py#L861
[2]: http://werkzeug.pocoo.org/
2018-06-15 07:24:22 -07:00
Bertrand Bonnefoy-ClaudetandJelle Zijlstra 15ad132393 Werkzeug stub fixes (#2229)
* Fix stub for werkzeug.exceptions.Aborter and abort

* `werkzeug.exceptions.abort` [1] was missing and is thus added here.
  It's also commonly used in Flask as `flask.abort`.
* They both always raise [2], hence the `NoReturn` return type.

[1]: http://werkzeug.pocoo.org/docs/0.14/exceptions/#werkzeug.exceptions.abort
[2]: https://github.com/pallets/werkzeug/blob/d129d17066768238139b8f8a5d667d9a4f4d68db/werkzeug/exceptions.py#L708-L713

* Fix stub for werkzeug.wrappers.AuthorizationMixin

The code [1] uses `@cached_property` [2], which is basically a Python
property, and optionally returns an `Authorization` [3] object.

[1]: https://github.com/pallets/werkzeug/blob/d129d17066768238139b8f8a5d667d9a4f4d68db/werkzeug/wrappers.py#L1462-L1466
[2]: https://github.com/pallets/werkzeug/blob/d129d17066768238139b8f8a5d667d9a4f4d68db/werkzeug/utils.py#L35
[3]: https://github.com/pallets/werkzeug/blob/d129d17066768238139b8f8a5d667d9a4f4d68db/werkzeug/datastructures.py#L2438
2018-06-14 09:04:18 -07:00
Ilya KonstantinovandJelle Zijlstra 978c0913c8 Add stub for first (#2141)
Reviewed by author in https://github.com/hynek/first/pull/22
2018-06-11 19:50:56 -07:00
MaxandGuido van Rossum a753abafcf Fix click.getchar return type (#1473) 2018-06-11 15:54:56 -07:00
Jelle ZijlstraandGuido van Rossum 764ee4eeec add pytz.ZERO and pytz.HOUR (#2180)
https://github.com/stub42/pytz/blob/master/src/pytz/__init__.py#L187
2018-06-11 11:27:34 -07:00
Guido van RossumandJelle Zijlstra af3b015aa8 mock.patch.object() attribute arg should be Text (#2210)
It works and is needed for code using the dreaded
'from __future__ import unicode_literals'.
2018-06-09 22:36:24 -07:00
Ilya KonstantinovandJelle Zijlstra 129df4957c pynamodb: fix rate_limited_scan defaults (#2167)
The `rate_limited_scan` method has defaults for all arguments, including `attributes_to_get` which was omitted.
2018-06-08 23:02:38 -07:00
Max RandJelle Zijlstra 34b926008e Remove Python 3.3 check in mock.pyi (#2201) 2018-06-05 15:30:28 -07:00
Max RandJelle Zijlstra 1dfe4f2ec7 Add condition argument to pynamodb model delete (#2182) 2018-06-05 08:18:46 -07:00
Sebastian RittauandJelle Zijlstra fcc1b7def4 Merge Python 2 and 3 versions of werkzeug (#2185)
The Python 2 version was slightly outdated compared to the Python 3
version.

The Python 2 version of Headers.__delitem__() had an optional argument
_index_operation that also exists in the implementation. But considering
this is internal use only, it was missing from the Python 3 version, and
it created problems with derived classes, I decided not to add it to
the merged stub. See also pallets/werkzeug#1051.
2018-06-05 08:16:23 -07:00
Nipunn KoorapatiandJelle Zijlstra b7ee95aa56 Move google.protobuf from 2 to 2and3 (#2174)
* Move google protobuf from 2 to 2and3

This should generally be ok. I ran the internal consistency
tests and they seemed to pass.

* Convert str to bytes

* repr to use str in google.protobuf.internal.containers
2018-05-31 21:47:11 -07:00
Robert CollinsandJelle Zijlstra 98badb6eff Fix mock patch.dict stub and add mock stub (#2173)
The dict stub was referring to an instance, not the type, leading to
__call__ being considered when using as a decorator, rather than
__init__.

mock is a backport of the stdlib module and should be defined the same.
2018-05-31 21:45:54 -07:00
Cyril JouveandJelle Zijlstra cedc2d962e jinja2 loader types (#2179) 2018-05-31 21:40:57 -07:00
Michael J. SullivanandGitHub 2ba90a65c0 Remove __all__ = ... from stubs (#2161)
The presence of a __all__ causes everything to not get picked up by
import *, which among other things breaks the new six.moves stubs.
2018-05-24 19:00:07 -07:00
Semyon ProshevandJelle Zijlstra 6a080cd0db Use assignments instead of redefinitions for aliases in attrs (#2143) 2018-05-17 20:27:34 -07:00
Michael LeeandJelle Zijlstra 97d9f2eb2c Ensures overloads are ordered from narrow to broad (#2138)
This commit reorders any overloads where the first overload was
"shadowing" the second, preventing it from ever being matched by type
checkers that work by selecting the first matching overload alternative.

For example, the first overload alternative below is strictly broader
then the second, preventing it from ever being selected:

    class Parent: pass
    class Child(Parent): pass

    @overload
    def foo(x: *int) -> Parent: ...
    @overload
    def foo(x: int, y: int) -> Child: ...

The correct thing to do is to either delete the second overload or
rearrange them to look like this:

    @overload
    def foo(x: int, y: int) -> Child: ...
    @overload
    def foo(x: *int) -> Parent: ...

Rationale: I'm currently [working on a proposal][0] that would amend
PEP 484 to (a) mandate type checkers check overloads in order and
(b) prohibit overloads where an earlier alternative completely shadows
a later one.

  [0]: https://github.com/python/typing/issues/253#issuecomment-389262904

This would prohibit overloads that look like the example below, where
the first alternative completely shadows the second.

I figured it would be a good idea to make these changes ahead of time:
if my proposal is accepted, it'd make the transition smoother. If not,
this is hopefully a relatively harmless change.

Note: I think some of these overloads could be simplified (e.g.
`reversed(...)`), but I mostly stuck with rearranging them in case I was
wrong. The only overload I actually changed was `hmac.compare_digest` --
I believe the Python 2 version actually accepts unicode.
2018-05-17 09:45:33 -04:00
Jelle ZijlstraandGuido van Rossum 463b4144dc explicitly import boto.regioninfo (#2121)
This may be causing intermittent test failures (see discussion on gitter).
2018-05-15 10:09:44 -04:00
Katelyn GiganteandJelle Zijlstra 51446f35fc Add stub for dateutil.rrule (#1808) 2018-05-15 09:04:57 -04:00
Andrew GaulandJelle Zijlstra 29bf24b8b9 Reparent simplejson from 2 to 2and3 (#2088) 2018-05-04 15:59:26 -07:00
David EurestiandJelle Zijlstra 863b9b0886 Add new factory arg to attrib and fields_dict (#2096) 2018-05-04 07:53:52 -07:00
David EurestiandJelle Zijlstra 664d30c44b Fix attr.Factory signature (#2077)
The first overload was catching all calls including take_self=True.
Fix it by modifying the overloads.

Fixes https://github.com/python-attrs/attrs/issues/366
2018-04-23 12:27:14 -07:00
Aaron MillerandJelle Zijlstra 8e62a79970 Fix type of click.Path path_type arg (#2066)
path_type takes a *type*, rather than instance of the type
2018-04-17 23:32:02 -07:00
Andrew GaulandJelle Zijlstra aa7d705ae8 Add hints to PyYAML dump methods (#2023) 2018-04-09 12:59:10 -07:00
Matt GilsonandJelle Zijlstra a994c47198 Fixup the boto stubs to allow mypy --strict. (#2032) 2018-04-08 12:41:04 -07:00
Jelle ZijlstraandGuido van Rossum 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 https://github.com/requests/requests/blob/d1fb1a29ab949223d8d64797e0fcc9a7d2690483/requests/status_codes.py#L102.
2018-04-06 11:36:43 -07:00
Alan DuandJelle Zijlstra 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
David EurestiandMatthias Kramm 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
Luka SterbicandMatthias Kramm 89cbd47344 Stubs for termcolor (#1935) 2018-03-20 15:32:50 -07:00
Leonardo FedaltoandJelle Zijlstra a9cce0c94b Add requests.utils.set_environ (#1973) 2018-03-20 11:15:52 -07:00
Dan SullyandJelle Zijlstra ef87943397 Update click.option to allow for user defined kwargs. (#1950)
Click's option decorator can take a cls= argument, which allows that class to parse arbitrary arguments from the decorator.
2018-03-07 10:32:55 -08:00
David EurestiandJelle Zijlstra df65f6ea15 Better type for click 'type' argument (#1903)
The call accepts tuples of types and callback methods
2018-03-06 21:41:21 -08:00
yed podtrzitkoandJelle Zijlstra 1fe9fd83fa validator.instance_of can contain sequence of types (#1920) 2018-03-06 10:18:33 -08:00
David EurestiandJelle Zijlstra 50c7188300 Work around mypy issue #4554 in attr.Factory (#1933)
This makes the following not give a type error:

   y: DefaultDict[str, List[int]] = Factory(lambda: defaultdict(list))
2018-03-05 19:21:14 -08:00
Matthias KrammandJelle Zijlstra 6c30806d07 add deprecation comment to mypy_extensions (#1943) 2018-03-05 18:51:14 -08:00