Commit Graph
29 Commits
Author SHA1 Message Date
Jukka Lehtosalo 306b4694ae Remove redundant definition of ast.PyCF_ONLY_AST (#2803)
This gets imported from `_ast`, so the definition was
redundant. This causes problems with the new mypy semantic
analyzer, as it will flag the redefinition as an error.
2019-02-20 17:12:11 +00:00
Jukka Lehtosalo 184148611a Fix signature of TypedDict has_key() (#2672) 2018-12-05 18:17:37 +01:00
Jukka Lehtosalo c8890b0f93 Add mypy fallback class for TypedDict methods to mypy_extensions (#2670)
This class is not defined at runtime but it's used by
mypy internally to support TypedDict methods.

Use NoReturn in argument types for better type safety
when the related mypy plugin hook is not active.
2018-12-04 18:21:58 +00:00
Jukka Lehtosalo eaeb5fcf13 Revert "Move Sized earlier in the bases of Sequence (#2602)" (#2657)
This reverts commit 4dc21f04dd.

Fixes #2655.
2018-11-30 14:48:55 +00:00
Jukka Lehtosalo 84548f5bba Revert "fix list concatenation (#2404)" (#2653)
The fix caused regressions for mypy that are difficult to
fix.  See https://github.com/python/mypy/issues/5492 for
context.

This reverts commit 1a42a2c3ea.
2018-11-29 12:20:29 -08:00
Jukka Lehtosalo 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 Lehtosalo 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 Lehtosalo 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
Jukka Lehtosalo 9b612c9218 Add TypedDict total argument (#1443)
See https://github.com/python/mypy/pull/3558 for context.
2017-06-29 08:38:13 -07:00
Jukka Lehtosalo f296b37e80 Fixes to unittest stubs (#1024)
* Fixes to unittest stubs

* Make types more precise
2017-03-18 14:35:33 -07:00
Jukka Lehtosalo f2579e532f Update signature of dict.get (#852)
Without this change, mypy can't infer proper types for cases like
`d.get(k, [])` where it needs type context to infer the type of
`[]`. We add the value type to the second argument to `get` using
union types, and this provides the context. This doesn't affect
the effective signature of `get`, other than providing the type
context for mypy.

Also removed some related redundant method definitions where we can
just inherit the base class definition. This makes it easier to
keep the method signatures consistent.

Note that this requires a few mypy PRs before mypy will be able to
use this effectively:

* https://github.com/python/mypy/pull/2718
* https://github.com/python/mypy/pull/2715
2017-01-20 07:41:54 -08:00
Jukka Lehtosalo c577c84a17 Add stub for cryptography.hazmat.primitives.serialization (#851)
This makes the stubs for cryptoraphy less incompelete. Created using
stubgen. I don't know what the types are.
2017-01-20 07:40:30 -08:00
Jukka Lehtosalo 35978a7ca5 Make signature of DictMixin.get consistent with Mapping.get (#838) 2017-01-17 14:08:49 +00:00
Jukka Lehtosalo 734ad44a11 Make MRO of UserDict.DictMixin consistent with Mapping (#837)
This fixes MRO conflicts produced by mypy when using multiple
inheritance.
2017-01-17 13:55:31 +00:00
Jukka Lehtosalo f39f9bf694 Make object_hook of json.load and json.loads optional (Python 2) (#757) 2016-12-07 13:32:56 -08:00
Jukka Lehtosalo e05edb60f1 Mypy stub fixes for strict optional mode (#366) 2016-07-13 09:38:40 -07:00
Jukka Lehtosalo b98580d299 Don't use basestring in tempfile stub (#205)
Fixes #202.
2016-05-24 16:45:48 -07:00
Jukka Lehtosalo d3d6a47302 Accept more unicode in 2.7 tempfile stubs (#201) 2016-05-16 13:37:15 +01:00
Jukka Lehtosalo 292447bd62 Misc stub fixes (#181) 2016-05-04 16:54:57 -07:00
Jukka Lehtosalo a5d5dcc4f4 Fixes to os.environ (#172)
Add os.environ.copy() to Python 2 stubs. Fix return
type of os.environ.copy().
2016-04-28 11:53:51 +01:00
Jukka Lehtosalo 8df19841bb Make Queue generic in Python 2, similar to Python 3 (#155) 2016-04-22 15:49:02 +01:00
Jukka Lehtosalo 5eaf522cde Fixes to urllib2 stubs (#154) 2016-04-22 13:19:37 +01:00
Jukka Lehtosalo fcef262a9b Support keyword arguments for dict() (Python 2) (#148) 2016-04-17 13:07:54 +01:00
Jukka Lehtosalo 70c2274e94 Update dict(...) to accept keyword arguments (#147)
We can't describe the fact that a keyword argument results in a 'str'
dictionary key in a stub. This needs to be handled elsewhere.
2016-04-16 16:30:15 +01:00
Jukka Lehtosalo bd36a37481 Add __setattr__ to object 2015-12-05 15:44:28 -08:00
Jukka Lehtosalo 4c547fc4f6 Add object.__new__
Not entirely sure about the right signature, though.
2015-11-29 12:18:42 -08:00
Jukka Lehtosalo d3efa5d6bc Add missing definitions to Python 3 'traceback' 2015-11-23 21:49:51 -08:00
Jukka Lehtosalo 9640fe569d Add directories for Python 2 and Python 3 stubs 2015-03-04 20:57:49 -08:00
Jukka Lehtosalo 893f49bd80 Initial commit 2015-03-04 20:51:28 -08:00