Sebastian Rittau
853c6e88a9
Merge stdlib/3.3 into stdlib/3 ( #2297 )
2018-07-03 18:56:28 -07:00
Sebastian Rittau
2a36b4cf01
Move asyncio from 3.4 to 3 ( #2307 )
2018-07-03 09:06:04 -07:00
Steven Karas
d4c15011e4
add __new__ to tuple in python2 ( #2304 )
...
this solves #2091 when checking Python 2 code (#2092 only fixed it for Python 3).
2018-07-03 08:18:01 -07:00
Sebastian Rittau
9229dd8f0c
Merge stdlib/3.4 into stdlib/3 ( #2303 )
...
* Merge stdlib/3.4 into stdlib/3
* Move asyncio back to 3.4 for now
2018-07-03 08:13:54 -07:00
Yusuke Miyazaki
1ae2ba0fbe
Use sys.platform instead of comments ( #2286 )
2018-07-03 08:13:04 -07:00
Yusuke Miyazaki
6192cce9d9
Avoid using string literals in type annotations ( #2294 )
2018-07-02 20:23:29 -07:00
Sebastian Rittau
25ad95de4f
Drop Python 3.3 support from asyncio and ipaddress ( #2293 )
2018-07-02 20:22:58 -07:00
Sebastian Rittau
d3865574a9
Remove asyncio.tasks.async ( #2296 )
...
While this alias for ensure_future existed prior to Python 3.7, it
causes a syntax error when parsing it with Python 3.7 or above.
2018-07-02 14:34:18 -07:00
Sebastian Rittau
ce1504d9e9
Add missing cls argument to FileFinder.path_hook() ( #2299 )
2018-07-02 13:19:04 -07:00
Sebastian Rittau
e767c38c37
Move lineno and col_offset to ast.AST ( #2298 )
...
Also, mark AST._attributes and _fields as class vars.
`lineno` and `col_offset` were previously defined on a few sub-classes of `AST`, e.g. `expr`, even though https://docs.python.org/3/library/ast.html explicitly states that `AST` has these two attributes. These attributes are only present if they were supplied as arguments to the constructor, but the same is true for the subclasses.
2018-07-02 13:18:38 -07:00
Ethan Smith
236ed3f731
Add genericpath stub ( #2300 )
...
To backport `os.path.commonpath` in mypy I needed to use genericpath. It seems unchanged since 3.4, and the `same*` functions were added in 3.4. (checked via comparing the `__all__`s of the source in 2.7, 3.4, and 3.7.)
2018-07-02 13:13:38 -07:00
Sebastian Rittau
6a18bd3ec2
Add missing self to TestCase.addCleanup() ( #2301 )
2018-07-02 12:12:59 -07:00
Yusuke Miyazaki
02192ecaf0
Install pytype from PyPI ( #2302 )
...
Fixes #2295
2018-07-02 11:57:20 -07:00
Yusuke Miyazaki
581705d9ee
Prefer to use ellipsis over pass ( #2292 )
2018-06-28 10:29:45 -07:00
Sebastian Rittau
187aaaced9
Use protocols for shutils.copyfileobj() ( #2291 )
...
See https://github.com/python/typing/issues/564 for background.
2018-06-28 10:28:24 -07:00
Sebastian Rittau
7ebd609643
Add pyexpat and xml.parsers ( #2276 )
2018-06-28 10:26:17 -07:00
potykion
f35c5d1349
Jinja2 async support ( #2278 )
2018-06-28 10:24:37 -07:00
Sebastian Rittau
b261b228ba
Merge Python 2 and 3 shutil ( #2259 )
...
* Drop support for Python 3.3
* Merge Python 2 and 3 shutil
* Marked some arguments optional
* Changed callback return type from None to Any for more flexibility
2018-06-27 20:42:58 -07:00
Yusuke Miyazaki
86883d3df9
Remove unused import statements ( #2282 )
2018-06-27 20:14:57 -07:00
Philipp Hahn
f8041d08db
logging.BASIC_FORMAT also for python2.7 ( #2283 )
2018-06-27 20:14:06 -07:00
Philipp Hahn
ee07115c96
urllib2.build_open() accepts instances and classes ( #2284 )
...
<https://docs.python.org/2/library/urllib2.html#urllib2.build_opener >
> handlers can be either instances of BaseHandler, or subclasses of
> BaseHandler (in which case it must be possible to call the constructor
> without any parameters).
2018-06-27 20:13:46 -07:00
Philipp Hahn
4e3b8f7e15
tty.set*() accepts fd or file object ( #2285 )
...
<https://docs.python.org/2/library/tty.html >
> ... requires the termios module ...
<https://docs.python.org/2/library/termios.html#module-termios >
> All functions in this module take a file descriptor fd as their first
> argument. This can be an integer file descriptor ... or a file object,
2018-06-27 20:12:04 -07:00
Nipunn Koorapati
b7df5a670a
Add type stubs for google.protobuf.service ( #2187 )
2018-06-27 15:38:29 -07:00
Guido van Rossum
5b32e79f4a
[gflags] Give DEFINE* default values Optional types ( #2279 )
...
I found some code that called DEFINE_integer() and DEFINE_float() with default set to None. Perusing the code that seems to be a totally valid usage. I am not super familiar with gflags but I believe this PR consistently changes all those default values to Optional[].
2018-06-26 13:53:39 -07:00
Yusuke Miyazaki
b91cb87249
Add a convention for platform-dependent APIs to CONTRIBUTING.md ( #2281 )
2018-06-26 09:14:12 -07:00
Ethan Smith
de1755b263
Remove type cycle in click ( #2277 )
2018-06-26 07:24:55 -07:00
Guido van Rossum
41e5fe4457
Message.WhichOneof returns Text, not bytes ( #2274 )
2018-06-23 15:42:13 -07:00
NAKAMURA Yoshitaka
16ed540c95
Fix type for imaplib.IMAP4.error and related ( #2273 )
2018-06-22 08:43:25 -07:00
Sebastian Rittau
39d95f16cf
Drop Python 3.3 support from importlib stubs ( #2264 )
2018-06-22 08:36:00 -07:00
Ethan Smith
507ad2dcbe
importlib.util.find_spec has optional return type ( #2270 )
2018-06-22 08:06:06 -07:00
Sebastian Rittau
95eff73ab2
Drop Python 3.3 support from several stubs ( #2265 )
...
* Drop Python 3.3 support from several stubs
* Revert wrong socketserver changes
2018-06-20 16:49:47 -07:00
Sebastian Rittau
b05e99297c
Drop Python 3.3 support from several stubs ( #2266 )
...
* Drop Python 3.3 support from importlib stubs
* Drop Python 3.3 support from html and symbol stubs
2018-06-20 16:46:11 -07:00
Sebastian Rittau
1184726417
Drop Python 3.3 support from email stubs ( #2263 )
2018-06-20 12:04:22 -07:00
John Reese
40b176b195
Fix annotation for difflib.SequenceMatcher.find_longest_match ( #2253 )
2018-06-20 10:52:39 -07:00
Michael Lee
fb92ee84c5
Make overloads in the Python 2 builtins with a 'None' fallback come first ( #2261 )
...
In short, this change makes sure calls like `map(None, a, b)` behave as
expected when using `--no-strict-optional` is enabled.
For additional context, see https://github.com/python/mypy/issues/5246
2018-06-20 08:26:06 -07:00
Sebastian Rittau
fa74160e1f
Drop support for Python 3.3 ( #2258 )
...
Closes #2257 .
2018-06-19 15:37:13 -07: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
Andrew Svetlov
a5b7ddd96c
Accepy bytes in sock.connect() and family ( #2252 )
2018-06-18 10:30:41 -07:00
Sekou Diao
96e3e23d9b
Add locale.windows ( #2251 )
...
This is undocumented but it exists (on all platforms AFAICT) and is used, so it should be added, marked `# undocumented`.
2018-06-18 09:19:55 -07:00
strager
e404bc7cd6
Allow pathlib.Path in zipfile.ZipFile ( #2238 )
...
`zipfile.ZipFile` is typed to accept `Text` for local and archive file
paths. In Python 3.6, several `ZipFile` methods accept `pathlib.Path`
objects, not just `str` objects. Generalize `ZipFile`'s methods so code
using `pathlib.Path` with `ZipFile` type-checks.
I verified (using my own project) that the following methods work with
os.PurePath at runtime on CPython 3.6:
* zipfile.ZipInfo.__init__
* zipfile.ZipInfo.extractall
* zipfile.ZipInfo.write
2018-06-18 08:29:23 -07:00
Daniel Li
1a8455b444
Add thread_name_prefix to ThreadPoolExecutor stub ( #2249 )
...
The thread_name_prefix argument of ThreadPoolExecutor.__init__ was added
to the Python 2 backport in agronholm/pythonfutures#64 .
2018-06-17 18:33:37 -07:00
Jelle Zijlstra
00cda79cf5
add io.TextIOWrapper.read in 3.3 ( #2248 )
...
This is needed to make TextIOWrapper and a few classes that inherit
from it concrete in 3.3. I am actually not sure whether this method
exists at runtime; there's nothing in
https://docs.python.org/3/library/io.html#io.TextIOWrapper
that suggests it was added in 3.4. In any case, it hardly matters
since 3.3 usage should be very rare now.
2018-06-17 23:47:07 +01:00
Jelle Zijlstra
3032fbdff1
make http.client.HTTPResponse concrete in 3.4 ( #2244 )
...
Matches the implementation in https://github.com/python/cpython/blob/3.4/Lib/http/client.py#L308
The ignore works around python/mypy#5027 (commented further up in the 3.5 branch).
Part of #1476 .
2018-06-17 17:29:02 +01:00
Jelle Zijlstra
da8de48f6d
UserList and UserString in 2.7 ( #2246 )
...
Fill out UserList and UserString stubs to make the classes concrete. Compare:
https://github.com/python/cpython/blob/2.7/Lib/UserList.py
https://github.com/python/cpython/blob/2.7/Lib/UserString.py
2018-06-17 17:24:30 +01:00
Jelle Zijlstra
8084dc1c1f
Fix abstract classes in 2.7 ( #2247 )
...
Part of #1476 .
2018-06-17 17:21:17 +01:00
Jelle Zijlstra
6b36b1befe
Iterator provides a concrete __iter__ in 2.7 (#2245 )
...
This is already how it works in the Python 3 stub.
`Iterator.__iter__` also exists at runtime: https://github.com/python/cpython/blob/2.7/Lib/_abcoll.py#L73 .
2018-06-17 12:00:42 +01:00
Jelle Zijlstra
0393de4bd7
fix some abstract classes in Python 2 ( #2240 )
...
Part of #1476 .
2018-06-17 00:56:00 +01:00
Philipp Hahn
7c3edba6ce
python2/gettext improvements ( #2235 )
...
* py2: gettext: info()
returns a Dict[str, str]
<https://docs.python.org/2/library/gettext.html#gettext.NullTranslations.info >
> Return the “protected” _info variable.
<https://docs.python.org/2/library/gettext.html#the-gnutranslations-class >
> The entire set of key/value pairs are placed into a dictionary and set
> as the “protected” _info instance variable.
* py2: gettext: charset()
returns an Optional[str]
<https://docs.python.org/2/library/gettext.html#gettext.NullTranslations.charset >
> Return the “protected” _charset variable.
<https://docs.python.org/2/library/gettext.html#the-gnutranslations-class >
> If the key Content-Type is found, then the charset property is used to
> initialize the “protected” _charset instance variable, defaulting to
> None if not found.
* py2: gettext: [set_]output_charset()
allows to set an Optional[str]
<https://docs.python.org/2/library/gettext.html#gettext.NullTranslations.output_charset >
> Return the “protected” _output_charset variable.
<https://docs.python.org/2/library/gettext.html#gettext.NullTranslations.set_output_charset >
> Change the “protected” _output_charset variable, which defines the
> encoding used to return translated messages.
<https://docs.python.org/2/library/gettext.html#gettext.GNUTranslations.lgettext >
> Equivalent to gettext(), but the translation is returned in the
> preferred system encoding, if no other encoding was explicitly set with
> set_output_charset().
* py2: gettext: install(..., names)
allows to set an Optional[str]
<https://docs.python.org/2/library/gettext.html#gettext.NullTranslations.install >
> If the names parameter is given, it must be a sequence containing the
> names of functions you want to install in the builtins namespace in
> addition to _().
* py2: gettext: localdir=None
is Optional[str]
<https://docs.python.org/2/library/gettext.html#gettext.bindtextdomain >
> If localedir is omitted or None, then the current binding for domain
> is returned.
* py2: gettext: languages=None
is Optional[Sequence[str]]
<https://docs.python.org/2/library/gettext.html#gettext.find >
> If languages is not given, then the following environment variables
> are searched: ...
* py2: gettext: codeset=None
is Optional[str]
<https://docs.python.org/2/library/gettext.html#gettext.translation >
> If provided, codeset will change the charset used to encode translated
> strings.
* py2: gettext: translation(class_=None)
is Optional[type]
<https://docs.python.org/2/library/gettext.html#gettext.translation >
> The actual class instantiated is either class_ if provided, otherwise
> GNUTranslations.
* py2: gettext: translation(fallback)
is bool
<https://docs.python.org/2/library/gettext.html#gettext.translation >
> ..., this function raises IOError if fallback is false (which is the
> default), and returns a NullTranslations instance if fallback is true.
* py2: gettext: install(unicode)
is bool
<https://docs.python.org/2/library/gettext.html#gettext.install >
> The unicode flag is passed to the resulting translation object’s
> install() method.
which is already expecting `bool`.
2018-06-16 10:19:24 -07:00