Commit Graph

1911 Commits

Author SHA1 Message Date
Sebastian Rittau
7be20fcf91 Return Any, not Union from IP parsing functions (#2499)
Closes: #2080
2018-10-01 08:48:39 -07:00
Adam Dangoor
45a11b974e Update parse_multipart return type to support Python 3.7 (#2474)
* Add encoding and errors parameters to cgi.parse_multipart stub.
2018-09-27 22:19:02 +02:00
Scott Colby
25c9fdc20d Add bytes as legal type for RawConfigParser.read. (#2484)
Add `bytes` as legal type for `RawConfigParser.read` in 3.7.

Closes #2476.

https://bugs.python.org/issue31307
2018-09-26 23:27:33 -07:00
Michael R. Crusoe
3af4ff9f94 PY2: UUID accepts both unicode and str (#2478) 2018-09-26 13:31:04 +02:00
spdkils
6968ff6cb0 error:"IPv4Network" has no attribute "hostmask" (#2482)
The hostmask property from the _BaseNetwork class was missing a stub.
This was causing type errors whenever using the hostmask property.

Fixes #2481.
2018-09-25 22:58:05 -07:00
Rebecca Chen
9fda6b20ec Make the signature of optparse.OptionParser.parse_args more precise. (#2464) 2018-09-25 21:15:10 -07:00
Israel Tsadok
2a30462c4a The filter function may return str, tuple or list (#2472)
In Python 2, the return type of filter depends on the iterable
parameter.
2018-09-25 20:26:23 -07:00
Siva Chandra
f73d060042 Use Text under Python 2 in shutil.pyi. (#2471) 2018-09-25 20:25:04 -07:00
Sebastian Rittau
9f98737119 weakproxy fixes (#2450)
* The callback argument to ref() and proxy() is optional, per documentation
* proxy() returns a ProxyType or CallableProxyType

Closes #1627
2018-09-25 20:23:02 -07:00
Michael J. Sullivan
65863bebf4 make __class__ refer to the current object's class (#2480)
This is just a direct rehash of #1549.
2018-09-25 18:04:37 -07:00
Michael R. Crusoe
2e0af18dda slices of MutableSequences are also MutableSequences (#2428) 2018-09-25 13:06:59 -07:00
Sebastian Rittau
ea2122741f os.path.exists (Py 3) accepts a file descriptor (#2451)
Closes #1653
2018-09-24 07:53:44 -07:00
Nathaniel Manista
cca6ee43e6 Fix traceback.FrameSummary's "line" parameter (#2470)
traceback.FrameSummary's "line" parameter is a string that is the text
of a line of code, not an int that is the line number of a line of
code.
2018-09-21 16:58:25 -07:00
Michael J. Sullivan
4f4a025409 Remove tuple's __init__ method (#2467)
The __new__ method should suffice, and having both interferes with providing
a __new__ in namedtuples, which we want to do to fix
https://github.com/python/mypy/issues/1279.
2018-09-18 20:01:14 -07:00
Sebastian Rittau
9827132d5b Fix return types in urllib.request (#2389)
* Tighten return types of URL handlers

* urlopen() etc. return a modified HTTPResponse

* Add missing methods to HTTPResponse
2018-09-18 16:45:09 -07:00
Emil Hessman
d70a6cbcc0 Add missing instance attributes to logging.LoggerAdapter (#2462) 2018-09-18 20:23:04 +02:00
Jelle Zijlstra
1bc1fc2117 add constructor arguments for TimeoutExpired (#2466)
Previously, constructing a TimeoutExpired directly worked because Exception allowed arbitrary kwargs. We fixed that recently, but now mypy gives an error on creating a TimeoutExpired with legal arguments.
2018-09-18 14:02:38 +02:00
Rebecca Chen
b7c262523b Fix the Python 2 signature of tempfile._TemporaryFileWrapper.write. (#2465) 2018-09-18 13:54:56 +02:00
Rebecca Chen
7dbc8748dc Add __iter__ method to codecs.StreamReader. (#2463) 2018-09-18 13:46:16 +02:00
Matthew Christopher
110ebf4bfe Add exc_text to LogRecord (#2461) 2018-09-18 13:39:05 +02:00
Matt Robinson
c1eb946324 Add name attribute to logging.Handler (#2459)
* Add name attribute to logging.Handler
* Replace some older type comments with variable annotations around the addition line.
2018-09-17 19:36:49 +02:00
Christian Haudum
daae0c7980 Allow any keyword argument in argparse add_argument() method (#2460)
Closes #2457
2018-09-15 22:05:15 +02:00
Rebecca Chen
9e72a7fd0c Fix the return type of decimal.Decimal.__new__. (#2458) 2018-09-15 18:12:52 +02:00
kitsuyui
5cda4224fe Add type hint for fold arguments to datetime.datetime and datetime.time when Python >= 3.6 (#2449)
`datetime.datetime()` and `datetime.time()` have started to support fold arguments from 3.6.

- https://www.python.org/dev/peps/pep-0495/
- https://docs.python.org/3.5/library/datetime.html#datetime.datetime
- https://docs.python.org/3.6/library/datetime.html#datetime.datetime
- https://docs.python.org/3.5/library/datetime.html#datetime.time
- https://docs.python.org/3.6/library/datetime.html#datetime.time
2018-09-11 18:30:29 -07:00
Dmitry Shachnev
c6c8d7e540 unittest: make assertIn/assertNotIn accept iterables (#2447)
Fixes #2381.
2018-09-11 18:48:44 +02:00
Sebastian Rittau
60548f122f AbstractEventLoop exception handler is optional (#2446)
Closes #1616

* get_exception_handler() is only available in 3.5
2018-09-11 08:26:57 -07:00
Sebastian Rittau
44bdf6c6c7 Fix RawConfigParser.readfp() annotation (#2443)
Closes #689
2018-09-11 08:22:36 -07:00
Zac Hatfield-Dodds
6afa610191 memoryview is a context manager (#2442)
Since Python 3.2, __enter__ returns self and __exit__ calls self.release()
2018-09-11 14:13:38 +02:00
Jelle Zijlstra
8b9e4c378a fix module argument to unittest.main (#2403) 2018-09-10 11:04:05 -07:00
Sebastian Kreft
c96812425a Overload the definitions of dataclasses.asdict and dataclasses.astuple (#2422) 2018-09-06 22:14:28 -07:00
Martin DeMello
19708fac61 add __enter__, __exit__ and __getattr__ to streamreader/writer (#2411) 2018-09-04 13:38:18 -07:00
Ivan Levkivskyi
8ed0159445 Remove duplicate method definitions in importlib and jinja2 (#2427) 2018-09-04 07:50:47 -07:00
Emil Hessman
50b5650a11 Add stub for datetime.time.fromisoformat introduced in 3.7 (#2426) 2018-09-04 16:35:56 +02:00
Siva Chandra
01abd34327 Use class with __call__ method instead of callable. (#2418)
This will enable checking positional and keyword parameters.
2018-09-03 09:50:01 -07:00
Zsolt Dollenstein
5ed39dd8ce bring protocols.pyi more inline with documentation (#2421) 2018-08-31 13:56:57 +02:00
Sebastian Rittau
bbe9b94b00 smtplib improvements (#2419)
* Mark SMTP attibutes with class defaults with "= ..."
* Add SMTP.command_encoding
* Annotate SMTP.__exit__()
* Add SMTP.auth() et al.
* Add LMTP_PORT constant
2018-08-27 20:22:19 -07:00
Anthony Sottile
c3cf369c6f Document required= argument for add_subparsers in py37+ (#2416) 2018-08-23 19:39:34 -07:00
Ollie Ford
2e7e8cc009 Add 3.7 variant of subprocess.run (#2409)
Python 3.7 added:
  - `text` as an alias of `universal_newlines`
  - `capture_output` for `stdout=PIPE,stderr=PIPE`

cf. https://docs.python.org/3.7/library/subprocess.html
2018-08-23 11:50:23 -07:00
Ran Benita
8ab951c371 profile.run(sort=...) can be a string (#2413)
The int form is only accepted for backward compatibility.
https://docs.python.org/3/library/profile.html#pstats.Stats.sort_stats
2018-08-22 07:48:18 -07:00
Philipp Hahn
df516fab59 Some optparse improvements (#2290)
* optparse.Option.dest is a string

* optparse.OptionParser.epilog is a string

* optparse.OptionParser.prog is string

* optparse.OptionParser.values is Values

Shuffle code to resolve forward reference

* optparse.OptionParser.*option_list is a list of Options

* optparse.OptionParser.parse_args returns 2-tuple

<https://docs.python.org/2/library/optparse.html#parsing-arguments>

* minor improvements to Values
2018-08-21 21:51:30 -07:00
Ilya Konstantinov
fe04d3aa2d Accept str in cast (#2408) 2018-08-21 07:53:35 -07:00
Jelle Zijlstra
9e023e7586 minor namedtuple fixes (#2227)
- The extra arguments aren't keyword-only in 2.7.
- Added the `defaults` argument in 3.7 (https://docs.python.org/3.7/library/collections.html#collections.namedtuple).
2018-08-19 03:47:10 +01:00
Goldstein
c3b5513475 Add annotations to runpy.pyi (#2395) 2018-08-18 19:25:48 -07:00
Matt Gilson
ebea29a0ed Make defaultdict.default_factory Optional. (#2401)
The API allows for setting this to `None`.  It makes the defaultdict behave more like a regular dict.

Fixes #2375.
2018-08-18 19:22:15 -07:00
Teddy Sudol
0386f3daec Change mode: unicode to mode: Text (#2398)
Resolves #2397
2018-08-17 16:33:35 -07:00
Sebastian Rittau
b209a649a0 Add date.fromisoformat() (#2393) 2018-08-17 08:50:10 -07:00
Sebastian Rittau
25ac4d6af4 Implement StartResponse using a protocol (#2392)
* Add ExcInfo and OptExcInfo type aliases

* Implement StartResponse using a protocol

* Mark stub-only types with an underscore

* Remove wrong TODO note

python/mypy#1178 is about variable-length tuples, while exc_info()
always returns a tuple with length 3. Ideally, exc_info() would
return Union[Tuple[Type[_E], _E, TracebackType], Tuple[None, None, None]],
but that is a different issue.
2018-08-17 08:36:00 -07:00
Sebastian Rittau
f25c9548ed Replace StartResponse arguments with ... (#2379)
StartResponse callbacks are required to accept and optional third argument.
Currently, there is no good way to describe this using type hints.
Previously, a Union was used, but that causes mypy to complain about any call
of start_response().
2018-08-15 10:41:39 -07:00
David Zbarsky
099081016e Add more mmap constants (#2386) 2018-08-15 10:39:47 -07:00
Sebastian Rittau
7ad682b0ae Improve annotations for json.load() and loads() (#2382)
* loads() only accepts str as first argument for Python < 3.6
* Use a protocol for the first argument to load() (cf python/typing#564)
2018-08-14 10:41:33 -07:00