Commit Graph
4778 Commits
Author SHA1 Message Date
mbarkhauandJelle Zijlstra d7067fb287 Add FormattedValue and JoinedStr to ast for py3.6+ (#2206)
Fixes #2205

For reference https://docs.python.org/3/library/ast.html#abstract-grammar
2018-06-08 19:13:17 -07:00
Max RandJelle Zijlstra 34b926008e Remove Python 3.3 check in mock.pyi (#2201) 2018-06-05 15:30:28 -07:00
Froger DavidandJelle Zijlstra ffba2ea87a compile builtin accept PathLike (#2200) 2018-06-05 14:02:46 -07:00
Froger DavidandJelle Zijlstra ae91695fb7 Inspect (#2178)
* add inspect.{isasyncgenfunction,isasyncgen} (3.6)

* reorder inspect.CO_* as in Python 3.6 doc

* add inspect.CO_{COROUTINE,ITERABLE_COROUTINE} (3.5)

* add inspect.CO_ASYNC_GENERATOR (3.6)

* use variable annotations

* use version checks

* Parameter.empty is a class attribute

* Signature.empty is a class attribute
2018-06-05 09:59:09 -07:00
Daniel LiandJelle Zijlstra e02eb70cb3 pkgutil.iter_modules accepts iterable of str (#2195) 2018-06-05 09:58:51 -07:00
Ivan LevkivskyiandGitHub 7dd4d0882d Update return type of dataclasses.field (#2197) 2018-06-05 16:57:20 +01:00
Jelle ZijlstraandGitHub cd4a5ff65c use pytype-single rather than pytype (#2198)
Looks like this happened in https://github.com/google/pytype/commit/3de774361b2481b55ef493391429e88571f7b9f2.
2018-06-05 08:34:21 -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
Anthony SottileandJelle Zijlstra 270fba2e4e Add headers attribute to HTTPResponse (#2190) 2018-06-05 08:11:12 -07:00
Michael Hirsch, Ph.DandJelle Zijlstra 48904699ec urlretrieve can accept filename: pathlib.Path for Python>=3.6 (#2194) 2018-06-05 07:58:39 -07:00
Jelle ZijlstraandŁukasz Langa eef0b1d562 fix type for TestCase.assertIn (#2186)
* fix type for TestCase.assertIn

This does essentially `assert member in container`, so we want a `Container`, not an `Iterable`.

This came up in https://github.com/ambv/black/pull/288/files/68e9d426a86edc187a3f58ea889a2002620f0de6..0bbee43d60dfc16d8bbdd0bbdaad754a2c8c7ec0#r192525658.

* use any for assertIn
2018-06-04 15:34:09 -07:00
MichaelandJelle Zijlstra 9ec6d476c4 Broaden type of val argument to locale.currency (#2192)
Similar to python/typeshed#1350
2018-06-04 07:54:26 -07:00
HanaasagiandJelle Zijlstra 7faa41984b Closes python/mypy/#5141 (#2191) 2018-06-03 21:52:19 -07:00
Anthony SottileandJelle Zijlstra 2d4bb04ab3 json.load can also take IO[bytes] in py36+ (#2188) 2018-06-03 19:02:55 -07:00
Stephen ThorneandJelle Zijlstra a25ff0bddf get_grouped_opcodes() returns an iterable of groups, not an iterable of opcodes. (#2183)
The type signature of get_grouped_opcodes() was incorrect. Resulting in type errors when checking return values.

The usage of this function is like this:
groups = sm.get_grouped_opcodes() # groups is Iterable[List[Tuple[str, int, int, int, int]]]
for group in groups:  #  group is List[Tuple[str, int, int, int, int]]
  for opcode in group:  # opcode is Tuple[str, int, int, int, int]
2018-06-01 09:59:57 -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
Sebastian RittauandJelle Zijlstra a3031adb46 Merge Python 2 and 3 SSL stubs (#2175) 2018-05-31 21:44:42 -07:00
Cyril JouveandJelle Zijlstra cedc2d962e jinja2 loader types (#2179) 2018-05-31 21:40:57 -07:00
Sebastian RittauandJelle Zijlstra c3897b4a14 A few werkzeug type fixes (#2181)
* BaseRequest.stream
* ResponseStreamMixin.stream
* get_content_length()
* get_input_stream()
2018-05-31 21:38:51 -07:00
George KingandJelle Zijlstra 66226ab2d7 Preliminary implementation of stdlib/3.7/dataclasses.pyi. (#1944) 2018-05-30 12:57:02 -07:00
Mathieu Leduc-HamelandJelle Zijlstra 351d019241 Mark inspect.getmembers as Optional for both Py2 and Py3 (#2172) 2018-05-29 10:43:34 -07:00
Jelle ZijlstraandGuido van Rossum da7b04904c Limit lines to 130 chracters (#2169)
Fixes #2124.

As mentioned in the issue, the current guidelines lead to extremely long lines of many hundreds of characters, which make code hard to read and review. I think there should be some limit to line length, but it's OK for stubs to have somewhat longer lines than normal code.

For reference, there are currently 115 lines in typeshed over 200 characters; 523 over 120 characters; and 2980 over 79 characters.

We picked 130 because that's the longest line GitHub displays on a 13" laptop in a unified diff without folding. There are currently 382 lines in typeshed that are over 130 characters.
2018-05-29 08:28:08 -07:00
Sushain CheriviralaandJelle Zijlstra 0193ee87a8 Add OpenDirector.addheaders and PEP 526 refactoring (fixes #2163) (#2164)
* Add OpenDirector.addheaders and replace type comments with annotations

* Use ClassVar/eliminate `= ...` and add BaseHandler.handler_order (exists in Py2 versions)
2018-05-28 08:09:35 -07:00
Sebastian RittauandJelle Zijlstra b1cd9fedf8 Complete wsgiref (#2165)
* Add wsgiref.handlers

* Add wsgiref.simple_server
2018-05-28 08:08:27 -07:00
Sushain CheriviralaandJelle Zijlstra dc0fcdcaa0 Add missing signals to Py2/3; missing events to Py2; PEP 526 refactoring (fixes #1576) (#2168) 2018-05-27 22:50:10 -07:00
Sushain CheriviralaandJelle Zijlstra 226f0553fe Add compact keyword arg to pprint (#2162) 2018-05-24 21:10:17 -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
Michael J. SullivanandGitHub c55cf13d8e make difflib use str on 3 and AnyStr on 2 (#2160) 2018-05-24 13:53:42 -07:00
Michael J. SullivanandGitHub db1316d26b os.path.relpath can use a default argument and still use str (#2159) 2018-05-24 13:23:17 -07:00
Sebastian RittauandJelle Zijlstra 8b84e9cf13 Improve wsgiref stubs (#2145)
* Use typing.Text

* Add InputStream and ErrorStream WSGI protocols

* Fix return type of WSGIApplication

* Add type hints to wsgiref.validate

* Replace _Bytes by plain bytes

* Add wsgiref.util

* Add wsgiref.headers

* ErrorWrapper.writelines() takes an Iterable

* Fix start_response return type
* Make Python 2 and 3 branches resemble each other more closely
* Use typing.NoReturn
* Fix WriteWrapper.writer type

* Change return type of WriteWrapper.writer to Any
2018-05-23 08:19:07 -07:00
Guido van RossumandJelle Zijlstra a392989a30 Add support for well_known_types to google/protobuf (#2157)
Fixes #2154
2018-05-22 21:57:07 -07:00
Jelle ZijlstraandGuido van Rossum b89f9553e9 keep os.path in 2 and 3 consistent (#2152)
We can't merge these because os/__init__ is still different.

Also slight refactor of tests/check_consistent.py to avoid `from os import path`.
2018-05-22 07:14:13 -07:00
Jakub NabagloandJelle Zijlstra d84069e78d Add stub for random.Random.choices (#2156) 2018-05-21 19:38:00 -07:00
Ilya KonstantinovandJelle Zijlstra 128a49a32d Fix LoggerAdapter.process first argument (#2153)
Standard implementation is:
```
def process(self, msg, kwargs):
    kwargs["extra"] = self.extra
    return msg, kwargs
```
so the signature is clearly `(Text, ...) -> (Text, ...)` (or `(str, ...) -> (str, ...)`, but following the other stubs here, I gather it's `Text`).
2018-05-21 08:27:16 -07:00
Michael LeeandJelle Zijlstra 709b193416 Rearrange overloads to account for optional arguments (#2150)
Basically, the same thing as [my previous pull request][0], except the
fixes are now focusing on functions with overlapping argument counts.

  [0]: https://github.com/python/typeshed/pull/2138
2018-05-19 09:20:16 -07:00
Semyon ProshevandJelle Zijlstra 6a080cd0db Use assignments instead of redefinitions for aliases in attrs (#2143) 2018-05-17 20:27:34 -07:00
Semyon ProshevandJelle Zijlstra 9275be244f Update NamedTuple _make and _replace parameters in Python 2 (#2144) 2018-05-17 11:03:55 -07:00
Dmitry FigolandJelle Zijlstra f7f00c52af socket.create_connection allows host to be None (#2136) 2018-05-17 09:45:59 -04: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
Zac Hatfield-DoddsandJelle Zijlstra d5929ada4d itertools.islice allows step=None (#2142) 2018-05-17 09:35:02 -04:00
Ethan SmithandJelle Zijlstra f4d19d9f61 Remove selenium stubs (#2137)
These stubs have not been used by anything for a while
(`remote` doesn't have a __init__.pyi). The quality of the stubs is also
lacking.
2018-05-16 11:50:01 -04:00
Ethan SmithandJelle Zijlstra 66545f147a Fix protobuf stubs (#2135) 2018-05-15 20:21:23 -04:00
Ethan SmithandJelle Zijlstra e9600db2ec Remove symlinks! (#2132) 2018-05-15 15:18:59 -04:00
Jelle ZijlstraandGuido van Rossum 537b97ed39 add bytearray.copy to Python 3 (#2133)
Fixes #1715.

2.7's bytearray doesn't have it.
2018-05-15 14:33:24 -04:00
Ethan SmithandJelle Zijlstra db9246b3e5 Fix importlib.resources for mypy (#2130) 2018-05-15 10:34:56 -04:00
Jelle ZijlstraandGitHub 55be42f6d6 add __fspath__ support to os.path (#2053)
Fixes #1997, #2068.

This is tricky because we need to get the return values right (see #1960 for
prior attempts) and we often run into python/mypy#3644. I found that I
could express most signatures correctly using a series of overloads.

A few other changes in here:
- Added splitunc, which according to https://docs.python.org/3/library/os.path.html
  should exist in both Unix and Windows.
- Made the second argument to os.path.curdir Optional to match the implementation.
- Fixed os.path.split, whose previous Path-aware signature triggered python/mypy#3644.
2018-05-15 10:31:40 -04:00
Alex VandiverandJelle Zijlstra 5505cb83bb Add generated stubs for google.protobuf, from its protobufs (#2095)
This fleshes out the auto-generated pieces of `google.protobuf`, by
using the go version of https://github.com/dropbox/mypy-protobuf to
generate mypy stubs from the .proto files in
https://github.com/google/protobuf/tree/master/src/google/protobuf

Generated from current `master` of google/protobuf, 25625b956a.

Ref google/protobuf#3803, python/typeshed#1705
2018-05-15 10:11:01 -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