Commit Graph

110 Commits

Author SHA1 Message Date
Sebastian Rittau
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
Sebastian Rittau
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
Michael Lee
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
Ethan Smith
e9600db2ec Remove symlinks! (#2132) 2018-05-15 15:18:59 -04:00
Daniel Li
56a31be7a7 Add stubs for submodules of six.moves (#2108)
To support "from six.moves.cPickle import loads", we must add a stub for
six.moves.cPickle as if it were a real submodule, even though it isn't
implemented as such. This fixes python/mypy#1550.

We don't apply this approach to six.moves.builtins on Python 2, because
it seems to confuse mypy.

We also add stubs for aliases in six.moves whose underlying modules have
been added to typeshed.

For Python 2:
    - six.moves.SimpleHTTPServer (alias for SimpleHTTPServer)

For Python 3:
    - six.moves.tkinter_dialog (alias for tkinter.dialog)
    - six.moves.tkinter_filedialog (alias for tkinter.filedialog)
    - six.moves.tkinter_commondialog (alias for tkinter.commondialog)
    - six.moves.tkinter_tkfiledialog (alias for tkinter.filedialog)
2018-05-12 12:02:44 -04:00
Charles-Axel Dein
5818893a7f Add default_exceptions to werkzeug.exceptions (#2071) 2018-04-19 09:03:24 -07:00
Jelle Zijlstra
6862434eae fix return type for itsdangerous.Signer.unsign (#2029)
Fixes #2011

Also fixed the argument type (it doesn't accept str).
2018-04-09 12:00:41 -07:00
Jelle Zijlstra
d24799fd31 uncomment a few parts of six.moves (#2019) 2018-04-06 11:20:14 -07:00
Jelle Zijlstra
0c15e5bdcc Improve werkzeug stubs (#1730) 2018-03-28 19:38:35 -07:00
Sebastian Rittau
6cf97b8db2 Proper types for Common{Request,Response}DescriptorsMixin (#1948)
* werkzeug: Add proper types for CommonRequestDescriptorsMixin

* werkzeug: Add proper types for CommonResponseDescriptorsMixin
2018-03-16 20:13:03 -07:00
rchen152
38dc8f5a6a Switch usages of mypy_extensions.NoReturn over to typing.NoReturn. (#1942)
* Change mypy_extensions.NoReturn to typing.NoReturn everywhere.
2018-03-05 12:42:29 -08:00
Sebastian Rittau
a08d57833f Fix werkzeug environ type (#1831)
* Fix werkzeug environ type

PEP 3333 explicitly calls for environ to be a built-in dict. Using a
Mapping will not only prevent the dict from being modified (which is
explicitly allowed by PEP 3333), it will also cause interaction
problems when the environment is passed to other WSGI handlers.

Also change the value type from object to Any for convenience. By
definition, the values can be anything and can't be type checked.
Using object instead of Any forces us to explicitly cast the value
whenever we access it.

* Use Union[str, unicode] for Werkzeug environment keys

This matches the type in wsgiref.types.

* Use WSGIEnvironment from wsgiref.types

* Add '= ...' to environ attribute
2018-01-26 14:30:23 -08:00
Jelle Zijlstra
fb2c7b34e2 Improve itsdangerous stubs (#1733) 2018-01-02 12:50:22 -08:00
Jelle Zijlstra
0eb7083f0e move dateutil into 2and3 (#1743)
These stubs are identical since #1735.
2017-12-23 06:38:55 -08:00
Sebastian Rittau
398401baee werkzeug: Mark BaseRequest.data as property (#1785) 2017-12-14 20:35:29 -08:00
Guido van Rossum
821c765991 Several packages always auto-import certain submodules on import (#1752)
* Importing yaml implies yaml.resolver

* Importing six implies six.moves

* Importing requests implies requests.packages
2017-11-17 15:15:40 -08:00
Jelle Zijlstra
8e75701eda make Python 2 and 3 dateutil stubs identical (#1735)
So that they can be merged into 2and3. This PR also adds a few missing
elements to parser.pyi and corrects some mistakes in the Python 3 stub.

Refer to https://github.com/dateutil/dateutil/tree/master/dateutil
2017-11-13 07:06:34 -08:00
Jelle Zijlstra
83ca997140 Change more defaults to ... (#1729)
* codemod ': Any = None' ': Any = ...'
* codemod ': (Union|Optional)([^=]+)\s+=\s+-?\d+' ': \1\2 = ...'
* codemod ': (Union|Optional)([^=]+)\s*=\s*-?(None|False|True)' ': \1\2 = ...'
* codemod ': (int|float|bool)\s*=\s*-?\d+' ': \1 = ...'
* codemod ': (bool)\s*=\s*(False|True)' ': \1 = ...'
* codemod ': Any\s*=\s*(False|True|None)' ': Any = ...'
2017-11-13 06:56:24 -08:00
Jelle Zijlstra
54dd6ba27c Change numerous default values to ... (#1722)
This is the convention, and some default values (e.g. strings) apparently
break pytype.
2017-11-09 06:28:40 -08:00
Jelle Zijlstra
735abe68dd remove all lxml stubs for now (#1664)
Fixes #525.
2017-11-07 07:54:01 -08:00
Ethan Smith
b7dc041f44 reexport names in 3/dateutil.tz (#1673)
This was missed in #1669, and should completely fix #1665.
2017-10-15 13:32:36 -07:00
aubanel
666f71fb56 Add a few methods to Element and ElementTree (#1585) 2017-09-22 07:11:15 -07:00
Alex Grönholm
023afbc098 Fixed the signature of six.raise_from() (#1563)
* Made the from_value argument optional in raise_from()

* Fixed six.raise_from() from_value and return type for both py2 and py3
2017-08-26 14:43:43 -07:00
Svyatoslav Ilinskiy
ee5e3affe1 Update Num stub for typed_ast 2.7 (#1430)
Field `n` should be a `Union[int, float, complex]`, not just `Union[int, float]`
2017-06-23 16:43:23 -07:00
Guido van Rossum
350563223f Add Optional[] for all remaining cases of x: <type> = None (#1424)
* Final round of adding Optional[] to type of arguments with default = None
* Update Travis to use --no-implicit-optionals and clarify CONTRIBUTING.md
2017-06-21 10:50:21 -07:00
Atul Varma
b8b3146904 Add PyJWT type annotations (#1281) 2017-06-20 13:19:09 -07:00
Emily Morehouse
b6d08b81a3 #1286 Remove header comments from stubs (#1292)
- Updates documentation related to previously required comment headers.
- Removes all comment headers from stubs
- Occasionally included a header for stubs that were noted to be incomplete or contained todo's.
2017-05-22 15:14:15 -07:00
Jelle Zijlstra
b9e896d97c make type aliases in lxml.etree private (#1216)
Naming the alias "AnyStr" isn't a great idea since AnyStr normally means
the typevar.

Also removed some whitespace in accordance with typeshed style.
2017-04-30 09:36:37 -07:00
David Euresti
759da86478 Cleanup six.moves module (#1180)
* Cleanup six.moves

Regenerate files so all imports are present, comment out imports that fail.
Remove useless files.

* Fix flake8
2017-04-21 16:03:19 -07:00
Guido van Rossum
3594b0e607 Fix JSONWebSignatureSerializer.load_dangerous() signature to satisfy mypy. (#1135)
The latest mypy complained that the signature didn't match that in the
superclass: Serializer.load_payload() has a serializer argument.  I
don't know this project but I think it's best to just add that
argument (rather than adding `# type: ignore`).
2017-04-04 09:51:56 -07:00
Jelle Zijlstra
37a854630c merge 2 and 3 stubs for requests (#1017)
* merge 2 and 3 stubs for requests

* fix version comparison
2017-03-18 16:39:40 -07:00
Semyon Proshev
4cd137189a Remove object as the only ancestor for classes in Python 3 stubs. 2017-03-18 14:57:57 -07:00
Jelle Zijlstra
97e1ffff40 Modify the Python 3 stubs for requests to be Python 2-compatible
This works towards fixing #924. To make the changes easier to review, I'm planning to
fix the issue in two steps:
- This commit makes the 3 stubs compatible with py2
- The next PR will move the 3 stubs to 2and3 and remove the 2 stubs

I wrote this code by diffing the files in third_party/{2,3}/requests and making
appropriate changes to the Python 3 stubs (mostly str/Text stuff). I verified
that the 3 stubs now pass mypy when parsed as 2.7, but I don't have an annotated
requests-using codebase to test on.
2017-03-17 10:27:47 -07:00
Jelle Zijlstra
349ff59f33 change empty bodies from "pass" to "..."
CONTRIBUTING.md says to prefer ... Not the most impactful change but fixing
these will allow us to lint for it in the future and get a consistent style.
2017-03-16 09:13:08 -07:00
Jelle Zijlstra
f35f6860f3 add missing types to some arguments in third_party/3 (#994) 2017-03-14 08:12:14 -07:00
Jelle Zijlstra
eb07fd3c1a make sure typevars defined in stubs are private (#989)
And also a few type aliases I noticed in the process.

Found using 59f9cac095
2017-03-13 07:32:40 -07:00
Hong Minhee
a6e3e70d14 Add incorrect/missing types to Werkzeug wrappers (#969) 2017-03-10 15:54:20 -08:00
David Fisher
6e34fc9127 Remove semicolon in type (#976) 2017-03-07 14:33:55 -08:00
David Euresti
8d42a2899a Add configparser and builtins to six (#937)
* Add configparser and builtins to six

* Use 'as' import
2017-02-20 11:38:49 -08:00
Ivan Levkivskyi
22c0353498 Add missing imports from typing (#933) 2017-02-14 10:59:00 -08:00
David Fisher
52dd4903d1 Update typed_ast for version 1.0 (#931) 2017-02-13 07:26:45 -08:00
Adam Marszałek
ca36070d51 Improved pytz support for timezone function (#911) 2017-02-03 10:54:59 -08:00
Adam Marszałek
6178ed3201 Expansion of unions inside params definition (#848)
Due to `Dict` / `Mapping` invariance it's necessary to include other variants of `Union[str, bytes], Union[str, bytes]`.
2017-01-20 09:09:22 -08:00
Alexey
741dd37422 Update annotations in requests.api for Python 3 (#849)
* Update annotations for requests.api.get

Argument params of requests.api.get accepts not only dictionaries of str, str pairs, but dictionaries and tuples of various types.
2017-01-19 14:09:58 -08:00
Roy Williams
aa6a1c53c9 Add stubs for dateutil.tz (#839) 2017-01-17 15:54:15 -08:00
David Fisher
2cb8e184cc Add NoReturn (#811)
* Add NoReturn
2017-01-04 13:38:05 -08:00
Roy Williams
844b32cc64 Fixup types 2017-01-03 10:17:20 -08:00
Roy Williams
7fd08cf073 Add more type information to requests.PreparedRequest 2017-01-03 10:17:20 -08:00
Alex Jurkiewicz
f8717ccfc4 Add support for request.get's 'params' param (#770)
* Add support for request.get's 'params' param

Requests defines the following API:
`get(url, params=None, **kwargs)`

* Improve typing for requests.get(params)

Add support for string form, and tighten restrictions for the dict form
to allow only string keys/vals. Technically, anything is allowed since
the code (I guess) runs `str(key)` and `str(value)`, but it seems better
to keep the stub somewhat strict so it can help pick up potential
errors.
2016-12-28 11:24:03 -08:00
Mateusz Kurek
43f18bc830 Use specific types in dateutil.relativedelta stubs
Improve operator methods for dateutil.relativedelta stubs:
* `__add__` operator method could return other types than `relativedelta` (`datetime.date` or `datetime.datetime`)
* use specific types of operators args instead of Any
* mypy currently does not handle `Union` in op methods (see python/mypy#2129, python/mypy#1442, python/mypy#1264 for details), so I've overloaded it directly
2016-12-28 11:18:03 -08:00