Commit Graph

414 Commits

Author SHA1 Message Date
Rebecca Chen
ea0a0fd17e Fix _StrType in difflib in Python 2. (#2514)
difflib functions accept unicode as well.
2018-10-12 14:39:24 +02:00
Siva Chandra
1b37ca4297 Make csv.reader take Iterator[Text] argument instead of Iterator[str]. (#2508) 2018-10-05 13:10:41 -07:00
Manuel Vázquez Acosta
1297caa27b Make 'datetime' a subclass of 'date'. (#2488)
Fixes #2487.
2018-10-01 20:19:02 -07:00
Jan Teske
94a1b09d1d Support PathLike arguments in the logging module. (#2500)
Since Python 3.6 logging.FileHandler's filename argument can be a
PathLike object. Same for FileHandler's subclasses.
logging.basicConfig passes its filename argument to a FileHandler, so
this can be a PathLike object too.
Finally, logging.config.fileConfig passes its fname argument to
ConfigParser.read, which also takes a PathLike since version 3.6.1.
2018-10-01 20:13:37 -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
Michael R. Crusoe
3af4ff9f94 PY2: UUID accepts both unicode and str (#2478) 2018-09-26 13:31:04 +02:00
Rebecca Chen
9fda6b20ec Make the signature of optparse.OptionParser.parse_args more precise. (#2464) 2018-09-25 21:15:10 -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 R. Crusoe
2e0af18dda slices of MutableSequences are also MutableSequences (#2428) 2018-09-25 13:06:59 -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
Emil Hessman
d70a6cbcc0 Add missing instance attributes to logging.LoggerAdapter (#2462) 2018-09-18 20:23:04 +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
Martin DeMello
19708fac61 add __enter__, __exit__ and __getattr__ to streamreader/writer (#2411) 2018-09-04 13:38:18 -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
Anthony Sottile
c3cf369c6f Document required= argument for add_subparsers in py37+ (#2416) 2018-08-23 19:39:34 -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
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
Yusuke Miyazaki
29522f87c3 Allow sqlite3.connect to take PathLike object on Python 3.7+ (#2380) 2018-08-11 22:49:49 -07:00
Ivan Levkivskyi
126b3e17fd Revert #2347 (#2377) 2018-08-09 13:22:12 -07:00
Ville Skyttä
066d8becf9 socket.create_connection source_address can be bytes or bytearray too (#2370)
* socket.create_connection source_address can be bytes or bytearray too

* Sync applicable socket.create_connection changes to socket.getaddrinfo
2018-08-09 10:02:34 -07:00
Ville Skyttä
850d16a668 socket.recv* return type improvements (#2363) 2018-08-09 08:07:17 -07:00
Chelsea Voss
f6e2fb4401 Allow DictReader values to be None (#2346) (#2347) 2018-08-09 08:04:44 -07:00
tikki
5a1ea5efb2 Minor fixes for zipfile (#2360)
* Add `is_dir` to `ZipFile`

* Allow `pathlib.Path` for `is_zipfile`
2018-08-06 09:48:53 -07:00
Ville Skyttä
7e62d3cdb1 Add missing sqlite3.dbapi2.Cursor return types (#2359) 2018-08-06 08:08:17 -07:00
Martin DeMello
0c9f0d21d2 allow for unicode entity dicts in saxutils (#2345) 2018-07-24 11:18:23 -07:00
Dominik Gabi
14fb9df49c Fix annotation shadowed by forward reference of preoprty in datetime constructor. (#2337) 2018-07-20 17:21:32 -07:00
Sebastian Rittau
4b8c37462e Fix decimal (#2323)
* Use Tuple field in DecimalTuple

* Remove unnecessary base classes from Decimal

* Decimal.__init__ -> __new__

* Decimal.__ne__ is not defined in Python 3

* Add Decimal.as_integer_ratio()

* Annotate DecimalException.handle()

* Correct types of Decimal method arguments

* Add missing arguments and optional markers to Decimal

* Add missing arguments to Context

* Remove spurious int from Unions with float

* Remove Context.__setattr__()

* Fix return types of Context methods
2018-07-18 21:59:08 -07:00
Ethan Smith
cc45366ca5 Merge 2/genericpath and 2and3/genericpath (#2330) 2018-07-13 14:07:15 -07:00
Ran Benita
0bc98a18f0 Add stdlib/2and3/imghdr stubs (#2318)
Ad defined in https://docs.python.org/3/library/imghdr.html.
2018-07-10 08:10:25 -07:00
Sebastian Rittau
a38dbc6c1e Merge decimal (#2306) 2018-07-09 19:03:01 -07:00
justinpawela
2a888416b2 Remove annotations from http.HTTPStatus enum members (#2314)
These type annotations are unnecessary and seem to confuse the type system.

* Remove annotation from PlistFormat enum members

Same rationale as python/typeshed#2314; same adverse effects observed.
2018-07-09 18:59:34 -07:00
NAKAMURA Yoshitaka
c78b9eb022 Allow IMAP4.search() to accept "None" charset as docs say (#2310) 2018-07-04 23:24:51 -07:00
Yusuke Miyazaki
6192cce9d9 Avoid using string literals in type annotations (#2294) 2018-07-02 20:23:29 -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
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
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