Bertrand Bonnefoy-Claudet
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-Claudet
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
Philipp Hahn
02c42c9cf6
optparse.Values.__getattr__ like argparse.Namespace ( #2228 )
...
optparse.Values is like argparse.Namespace and also has a __getattr__() method to return the parsed options.
Apply commits 54b4983 and 9ae0c0b from python/typeshed#25
2018-06-14 06:13:10 -07:00
Anthony Sottile
be3c43cf63
A Thread(target=...) function can return anything ( #2224 )
2018-06-13 11:50:17 -07:00
Martin DeMello
caff008ff2
test files under stdlib/2and3 with both python versions ( #2222 )
...
* test files under stdlib/2and3 with both python versions
2018-06-12 15:48:00 -07:00
Anthony Sottile
c4ee2ed36a
Correct annotation for fileinput.input ( #2223 )
...
```python
import fileinput
with fileinput.input(files=('foo.txt',), inplace=True, backup='') as f:
for line in f:
print(f'prefix{line}', end='')
```
```
$ mypy test2.py
test2.py:3: error: "Iterable[str]" has no attribute "__enter__"; maybe "__iter__"?
test2.py:3: error: "Iterable[str]" has no attribute "__exit__"
```
```
$ mypy test2.py --custom-typeshed typeshed
$
```
2018-06-12 15:45:11 -07:00
Jelle Zijlstra
de86f15fa0
Make http.client.HTTPResponse a BinaryIO ( #2218 )
...
Fixes #2189 .
The errors from mypy are a false positive (see python/mypy#5027 ).
2018-06-12 09:20:24 -07:00
Jelle Zijlstra
6bbf3d89eb
Further improve codecs stubs ( #2217 )
...
- remove header comments
- uppercase type aliases
- remove old-style type annotations
- unquote forward refs
- reformat the file
- remove values for globals
- don't use private names from codecs stub in io.pyi
2018-06-11 22:24:34 -07:00
Ilya Konstantinov
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
Roy Williams
52c02a2364
Allow Any type to be acceptable for the msg parameter in `logging.{info, warn, error, ...} ( #1776 )
...
The stdlib accepts any value here as long as it is castable to a string:
https://github.com/python/cpython/blob/3.6/Lib/logging/__init__.py#L336
https://github.com/python/cpython/blob/2.7/Lib/logging/__init__.py#L319-L330
Ideally this would use Protocols but I don't see them in use in typeshed yet.
2018-06-11 16:10:31 -07:00
Max
a753abafcf
Fix click.getchar return type ( #1473 )
2018-06-11 15:54:56 -07:00
Jelle Zijlstra
bdb06b5b81
improve codecs stubs ( #2114 )
...
Started out as progress towards #1476 , but I ended up fixing a few more things:
- fixed the signature of _encode_type, which actually returns a pair, not a string
- made some attributes into properties in order to prevent the descriptor protocol from turning them into methods
- found a bug in CPython in the process (python/cpython#6779 )
I used the following test file to make sure these classes are now instantiable:
```python
import codecs
import io
from typing import IO
bio = io.BytesIO()
cod = codecs.lookup('utf-8')
codecs.StreamReaderWriter(bio, codecs.StreamReader, codecs.StreamWriter)
codecs.StreamRecoder(bio, cod.encode, cod.decode, codecs.StreamReader, codecs.StreamWriter)
```
2018-06-11 15:53:15 -07:00
Jelle Zijlstra
d2469c0e89
fix type for itertools.product ( #2129 )
...
Fixes #1850 .
The fix was already applied to Python 2, but the typevar-based solution there
leads to "cannot infer value of type variable" in mypy. I used the following
script to check:
```python
from itertools import product
reveal_type(product([1]))
reveal_type(product([1], ['x'], [False], [3.0], [(1,)], [('x',)], [{1}], [{1: 2}], repeat=5))
```
2018-06-11 15:52:44 -07:00
Jelle Zijlstra
ced5d61bb6
make urllib.response.addinfourl instantiable ( #2134 )
...
Fixes #1377 (because HTTPError is a subclass of addinfourl). Also part of #1476 .
2018-06-11 15:43:53 -07:00
Guido van Rossum
c4bf27b835
Copy __builtin__.pyi to builtins.pyi, to fix breakage caused by #2128 ( #2215 )
2018-06-11 15:10:22 -07:00
Jelle Zijlstra
4e6af84640
improve multiprocessing.Pool types ( #2126 )
...
Fixes #1703
Mostly introduce typevars to express that the return types match the return types of the
callbacks.
Removed comment about incompleteness since all documented classes from
https://docs.python.org/3/library/multiprocessing.html#module-multiprocessing.pool
are covered.
2018-06-11 14:42:57 -07:00
Jelle Zijlstra
82c930e66c
Improve asyncio.tasks stubs ( #2139 )
...
- Use PEP 526-style variable annotations where possible
- Use FrameType instead of Any
- Remove workaround for mypy issue that was since fixed
2018-06-11 14:40:54 -07:00
Jelle Zijlstra
f5a74fd5da
remove Optional from type of __slots__ ( #2128 )
...
Fixes #1853
2018-06-11 14:29:11 -07:00
Guido van Rossum
c5e98308c0
Copy stdlib/3.4/enum.pyi to third_party/3/enum.pyi to satisfy tests ( #2214 )
...
Fix test breakage caused by #2118 .
2018-06-11 14:28:47 -07:00
Jelle Zijlstra
f65caed181
allow socket.recv_into to take a memoryview ( #2127 )
...
Fixes #1862
2018-06-11 14:25:11 -07:00
Jelle Zijlstra
cb293ebd2e
switch order of base classes on awaitable classes ( #2125 )
...
Fixes #1940 .
This makes it so that mypy will infer the common base class of these
classes to be Awaitable instead of Iterable. I verified that this
fixes the errors in the script posted by @neilconway.
2018-06-11 14:20:31 -07:00
Jelle Zijlstra
7abcd0f71f
add ConfigParser.readfp in Python 3 ( #2123 )
...
https://docs.python.org/3/library/configparser.html#configparser.ConfigParser.readfp
Fixes #2112
2018-06-11 14:10:52 -07:00
Jelle Zijlstra
53fde2ddf7
make timeout argument to Connection.poll Optional ( #2122 )
...
Fixes #2094
2018-06-11 14:04:45 -07:00
Jelle Zijlstra
91af6291b1
make shlex.shlex and multiprocessing.pool.IMapIterator instantiable ( #2120 )
...
Part of #1476 .
2018-06-11 14:04:05 -07:00
Jelle Zijlstra
c5bc3bd7fa
make contextvars.Context instantiable ( #2119 )
...
Part of #1476 .
2018-06-11 14:03:02 -07:00
Jelle Zijlstra
f789ee25ad
make EnumMeta instantiable ( #2118 )
...
part of #1476 . Verified that len(Enum) is still allowed by mypy.
2018-06-11 14:02:16 -07:00
Jelle Zijlstra
f73351f5bf
make tracemalloc.Traceback instantiable ( #2117 )
2018-06-11 14:01:46 -07:00
Jelle Zijlstra
28f6c095d4
make http.cookies.{Base,Simple}Cookie instantiable ( #2116 )
...
Part of #1476 .
2018-06-11 14:01:17 -07:00
Jelle Zijlstra
a33a124537
make BZ2File and LZMAFile instantiable ( #2115 )
...
Part of #1476 .
2018-06-11 13:59:38 -07:00
Jelle Zijlstra
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
Yusuke Miyazaki
46a59fc9b1
Add nis stub ( #2213 )
2018-06-11 11:26:32 -07:00
Jelle Zijlstra
38fb53eab6
add __init__ to SimpleNamespace ( #2207 )
...
```In [11]: SimpleNamespace(x=3)
Out[11]: namespace(x=3)
```
2018-06-11 08:08:41 -07:00
Daniel Li
87c296c964
Some inspect.formatargspec args cannot be None ( #2212 )
...
The annotations, formatarg, formatvarargs, formatvarkw, formatvalue,
formatreturns, and formatannotations arguments to inspect.formatargspec
have default values, but they cannot be None.
2018-06-11 08:07:47 -07:00
Guido van Rossum
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
Ethan Smith
7831f8d883
Add _winapi stub ( #2209 )
...
This module is going to be used by mypy for the daemon on Windows. To that end I ran stubgen on _winapi, then read through Modules/_winapi.c to add the function types. This seems to have been added in Python 3.1, but I think it is completely fine to just leave it in stdlib/3.
2018-06-09 18:48:30 -07:00
Scott Belden
84cafafe73
TracebackType is optional ( #2202 )
2018-06-09 16:22:50 -07:00
mbarkhau
8d852c3785
3.6+ Updates for ast module ( #2208 )
...
Added AnnAssign
Added comprehension.is_async
Fixed typo on FormattedValue.format_spec
2018-06-09 10:30:39 -07:00
Ilya Konstantinov
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
mbarkhau
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 R
34b926008e
Remove Python 3.3 check in mock.pyi ( #2201 )
2018-06-05 15:30:28 -07:00
Froger David
ffba2ea87a
compile builtin accept PathLike ( #2200 )
2018-06-05 14:02:46 -07:00
Froger David
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 Li
e02eb70cb3
pkgutil.iter_modules accepts iterable of str ( #2195 )
2018-06-05 09:58:51 -07:00
Ivan Levkivskyi
7dd4d0882d
Update return type of dataclasses.field ( #2197 )
2018-06-05 16:57:20 +01:00
Jelle Zijlstra
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 R
1dfe4f2ec7
Add condition argument to pynamodb model delete ( #2182 )
2018-06-05 08:18:46 -07:00
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
Anthony Sottile
270fba2e4e
Add headers attribute to HTTPResponse ( #2190 )
2018-06-05 08:11:12 -07:00
Michael Hirsch, Ph.D
48904699ec
urlretrieve can accept filename: pathlib.Path for Python>=3.6 ( #2194 )
2018-06-05 07:58:39 -07:00
Jelle Zijlstra
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