364 Commits

Author SHA1 Message Date
Dave Halter 74b5289e33 Make sure that the context manager for sqlite3.Connection works
This was originally reported in https://github.com/davidhalter/jedi/issues/1084.
2019-12-14 02:00:09 +01:00
Reid Swan 3e638aa3c3 Add __enter__, __exit__ to IMAP4, make __init__ arguments optional (#3540)
Fixes #3537
2019-12-13 12:05:57 +01:00
Ophir LOJKINE fda384fe0a Add date.__radd__ and datetime.__radd__ (#3539)
Fixes #3538
2019-12-12 18:38:51 +01:00
Alois Klink a06abc5dff Make fieldnames of csv.DictReader Optional (#3534)
Also run stdlib/2and3/csv.pyi through black and isort
2019-12-09 20:22:42 +01:00
Dylan Anthony 9b63192390 Update orjson stub from orjson repository(#3532) 2019-12-06 15:59:27 +01:00
Jacob Ilias Komissar 39ebd62e71 Update stub for socket module (#3451)
* Add new socket constants from 3.7 and 3.8
* Also move TCP_NOTSENT_LOWAT to 3.7 section and add AF_ALG to AddressFamily
* Add missing and updated socket module (and class) methods
* Improve formatting of socket.pyi
    * Add missing line breaks in long function parameters
* Reorder to mirror module documentations
* Fix type of create_server's family parameter
* Add more system conditionals
* Remove CAPI; it isn't an int (it's a PyCapsule)
* Slightly improve version conditions in socket.pyi
* Add incomplete signatures for socket.sendfile and .sendmsg_afalg
* Add VM_SOCKETS_INVALID_VERSION to socket.pyi
* Remove private _GLOBAL_DEFAULT_TIMEOUT from socket.pyi
* Add mode-dependent return types to socket.makefile
    - For Python 2, return and mode types are based on those of 'open'
    - For Python 3, types are based on actual behaviors
* Mark recv_into and recvfrom_into's nbytes argument as optional
* Improve docstring for socket stub
2019-12-05 08:13:06 +01:00
Alois Klink 4766ca0846 Use Literal to improve SpooledTemporaryFile (#3526)
* Run black code formatter on tempfile.pyi
* Use Literal to improve SpooledTemporaryFile

Previously, SpooledTemporaryFile was always an AnyStr.
Now, we load a SpooledTemporaryFile[bytes] if we open in bytes mode,
and we load a SpooledTemporaryFile[str] if we open in str mode.
2019-12-05 08:04:53 +01:00
hauntsaninja 6b321548c4 random: fix type for sample (#3525)
Fixes #3374
2019-12-04 13:07:24 -08:00
cshesse 9a32f0d26a add raw property to BufferedIOBase (#3483) 2019-12-04 08:20:07 +01:00
toppk 86775c803e Minor fixes to cryptography (x509) (#3520) 2019-12-03 18:29:05 +01:00
Jelle Zijlstra 97f830030c Simplify WatchedFileHandler.__init__ (#3506)
Fixes #3502
2019-12-03 14:54:29 +01:00
Jelle Zijlstra d215f502c6 Improve warnings stubs (#3501)
* merge 2and3 for _warnings

* move warn and warn_explicit into _warnings
2019-12-03 14:33:37 +01:00
toppk b585c96e5d padding can take an int or an object (PSS.MAX_LENGTH) (#3521) 2019-12-03 13:26:16 +01:00
Ran Benita 3934da12f6 __future__: add _Feature.compiler_flag (#3522)
Documented under the "CompilerFlag" paragraph here:
https://docs.python.org/3/library/__future__.html
2019-12-03 13:17:03 +01:00
Katelyn Gigante e8647d2d1d A few return annotations for redis client (#3517) 2019-12-02 21:06:11 -08:00
Maksim Kurnikov f7f68607ab SMTPChannel.push() accepts str (#3516) 2019-12-01 05:22:49 -08:00
Eugene Ha 92716c6821 Optional initial-value parameter for itertools.accumulate() (#3503) 2019-11-29 11:08:26 -08:00
Rune Tynan 359817bde9 In python versions 3.7 and above, re-export Pattern and Match (#3510) 2019-11-29 06:03:45 -08:00
hauntsaninja 5fdd6ad1a5 builtins.print: make sep and end Optional (#3468) (#3511)
The docs for Python 2 and Python 3 both explicitly mentions that None is a
valid value for sep and end.
https://docs.python.org/3/library/functions.html#print
2019-11-29 06:02:30 -08:00
robertschweizer a9a4fd0d42 Add ImportError constructor arguments (#3512) 2019-11-29 06:01:30 -08:00
Denis Eliseev 74ac70bd28 Fix the signature of unittest.TestCase.assertLogs #3513 (#3514) 2019-11-29 06:00:16 -08:00
Jason Fried 615fa41c25 asyncio/future.pyi - wrap_future loop keyword arg (#3507)
https://docs.python.org/3.8/library/asyncio-future.html?highlight=wrap_future#asyncio.wrap_future but it doesn't look like the signature has changed going back to 3.5
2019-11-26 16:03:54 -08:00
Sebastian Rittau 595d02363a Change return type of Message.get_payload() to Any (#3504)
If, for example, is_multipart() is called before calling get_payload(),
it is guaranteed that a List[Message] is returned.
2019-11-26 08:03:15 -08:00
Rune Tynan 643b955edb Modulefinder stubs (#3497) 2019-11-25 21:21:32 -08:00
Benjamin Peterson 23c531df5a Type socketserver's RequestHandlerClass as a callable. (#3422)
It's not uncommon to pass functions rather than actual types into the servers.
2019-11-25 20:18:17 -08:00
Ryan Hileman 693678b4c3 add no_type_check_decorator stub for #2884 (#3460) 2019-11-25 19:46:57 -08:00
Rune Tynan e2cf7c1bcf Add mailcap module (#3482) 2019-11-25 19:46:28 -08:00
Tuomas Suutari 56688240a1 mailbox: Fix signature of Mailbox.update method (#3493)
The `update` method calls `self[key] = message` for each `(key, message)`
pair so it also accepts all the same message types as the `__setitem__`
method.  Fix the signature so that the inputs are not restricted to
`Message` instances or to instance of the `_MessageType` type parameter,
but to the more reluctant `_MessageData` type alias.
2019-11-25 19:45:53 -08:00
Michał Słapek 41bf6a1982 Refactor warnings.catch_warning to be a class. (#3499) 2019-11-25 19:35:27 -08:00
Mohammed El-Afifi c76a298ffa Fix type hints in Template class (#3491)
Nothing in the standard library documentation for the string module suggests that the value associated with any key in the mapping parameter(or kwds) to Template.substitute and Template.safe_substitute should be a string. In fact any object can be used, for example

Template("$number is a number.").substitute({"number": 1})

The above code sample currently causes an error message like this:

error: Dict entry 0 has incompatible type "str": "int"; expected "str": "str"

which obviously shouldn't be emitted. Also a similar logic is already in place for methods in the Formatter class. However as I saw the notice about loose types above the Formatter class, I opted to use `object` instead of `Any` as the implementation inside the affected functions just uses the built-in str function on values inside mappings.
2019-11-24 18:16:48 -08:00
Tuomas Suutari 90004af132 mailbox: Couple small fixes (#3490)
* mailbox: Make stub-only helpers private

These HasIteritems and HasItems protocols don't exist in the real
mailbox module so prefix them with underscore to indicate they are
private.

* mailbox: Fix type of message argument

The Mailbox.add and Mailbox.__setitem__ methods take a message argument
which can be anything that is convertible to a Message.  Fix the
signatures accordingly.
2019-11-24 17:54:58 -08:00
Jelle Zijlstra 1f0dc6ee05 timeout argument to urllib.request.urlopen is Optional (#3487)
The docs (https://docs.python.org/3/library/urllib.request.html#urllib.request.urlopen) aren't very precise about this, but passing `None` seems to work in practice.
2019-11-24 12:51:33 +01:00
Jelle Zijlstra a89f883878 stream argument to pprint.pprint is Optional (#3488)
None is the default; see https://docs.python.org/3/library/pprint.html#pprint.PrettyPrinter
2019-11-24 12:29:43 +01:00
cshesse 91f445ef11 fix incorrect param name in FileIO (#3484) 2019-11-24 00:08:53 +01:00
Sebastian Rittau c0d46a2035 Mostly undo #3372 (#3481)
readline callback must return str, not bytes.
2019-11-23 20:17:14 +01:00
Steven Kalt 1871e50936 Py37 compileall add invalidation mode (#3476) 2019-11-23 07:20:54 -08:00
Steven Kalt 036a278624 annotated ZipInfo.from_file (#3478)
Closes: #3477
2019-11-23 16:16:25 +01:00
cshesse 9c87b24041 Add default value to BaseContext.Pipe() (#3479) 2019-11-23 16:12:45 +01:00
Rune Tynan cd45623ab7 Mailbox stubs (#3427) 2019-11-22 21:03:31 -08:00
Ivan Levkivskyi 8df632bca5 Fix some issues in cryptography package (#3474)
Note: the verifier() methods are not in docs, but they don't look private and are actually used in some code.
2019-11-21 17:05:22 +00:00
Martijn Pieters c53bc5a7ab Add missing elements for multiprocessing.dummy (#3471)
`multiprocessing.dummy` exports names that were not yet listed in the typeshed stub:

```python
>>> from multiprocessing import dummy as mpdummy
>>> imported_objects = (
...     (name, obj) for name, obj in vars(mpdummy).items()
...     if name in mpdummy.__all__ and not obj.__module__.startswith("multiprocessing.dummy")
... )
>>> print(*(f"{name}: {obj.__module__}" for name, obj in sorted(imported_objects)), sep="\n")
Barrier: threading
BoundedSemaphore: threading
Condition: threading
Event: threading
JoinableQueue: queue
Lock: _thread
Queue: queue
RLock: threading
Semaphore: threading
current_process: threading
```

Of these, only `JoinableQueue` was listed.
2019-11-20 10:40:12 +00:00
Christopher Hunt e065803980 distutils.fancy_getopt short option is optional (#3469) 2019-11-20 10:34:04 +00:00
Denis Laxalde 838e02334e Fix type of imp.find_module() (#3465)
find_module is documented to return a tuple (file, pathname,
description) where "file" is open file object and "description" a tuple
(suffix, mode, type). The type of "file" was wrong ("str" instead of
"IO[Any]") as well as that of "suffix" ("IO[Any]" instead of "str");
probably those type definitions were swapped.

Fixes #3466.
2019-11-20 10:29:05 +00:00
Michał Słapek 34d68ab0a2 Add warnings.catch_warning type hints with Literal. (#3464)
Closes: #3463
2019-11-14 11:08:50 +01:00
Ryan Morshead 8b6cd5c3f0 ast.Dict keys can be None (#3462)
See https://greentreesnakes.readthedocs.io/en/latest/nodes.html#Dict
2019-11-13 20:09:30 +01:00
Jeremy Lainé ba520034c7 Add type hints for audioop module (#3428) 2019-11-13 07:02:14 -08:00
Sebastian Rittau 107eaeb3d2 Add sys.addaudithook() and audit() (#3455) 2019-11-11 13:22:28 -08:00
Sebastian Rittau 66778639a5 Run CI tests against win32 and darwin platform (#3457)
Also use Python 3.8 as default Python version for tests
2019-11-11 07:52:11 -08:00
Ivan Levkivskyi 05780a0d11 Fix errors discovered by running typeshed check on Windows (#3456)
Fix errors discovered by running typeshed check on Windows. This is a temporary fix for #3446 (in long term we should figure out why these were not caught by typeshed CI).

I also remove an outdated comment while I am at it.
2019-11-11 12:18:58 +00:00
Ran Benita e55dad5dd0 sys: add pycache_prefix (#3454)
New in Python 3.8:
https://docs.python.org/3.8/library/sys.html#sys.pycache_prefix
2019-11-10 23:09:45 +01:00
Daniel Hahler 2f65683d7b Fix type for os.terminal_size to Tuple (#3450) 2019-11-10 19:30:12 +01:00
Michael Seifert 97ecd2b91f Change the return type of __reduce__ and __reduce_ex__ to Union[str, Tuple[Any, ...]] (#3453)
This allows subclasses to return strings (which are allowed) from these
methods without having mypy throwing an error.

Closes #3452
2019-11-10 15:48:56 +01:00
Sebastian Rittau d60b7ae26d New libs: Change permission requirement to notification (#3443)
This was discussed on the typing-sig mailing list and in
python/peps#1218, has met the approval of the steering council, and
was incorporated into PEP 484.
2019-11-07 07:35:35 -08:00
Sebastian Rittau 79d4e0dd08 Add assorted werkzeug type hints (#3444)
* Annotate is_immutable()
* Annotate ImmutableListMixin and make generic
* Make ImmutableList generic and derive from generic List
* Annotate Accept
* Annotate MIMEAccept
* Fix annotation of parse_accept_header()
2019-11-06 10:37:18 -08:00
Sebastian Rittau e4677d9ed4 Use async syntax instead of @coroutine (#3441) 2019-11-06 07:39:09 -08:00
Sebastian Rittau add0b5e930 Add functools.cached_property (#3439)
Part of #3319
2019-11-06 07:21:32 -08:00
Markus Bauer f39c102eb8 Add more stubs to redis (pubsub and monitor) (#3442) 2019-11-06 12:05:51 +01:00
Diego Elio Pettenò 99a6fb3108 Add the (deprecated) assertDictContainsSubset() to TestCase. (#3437)
Until this is removed from the standard library, it probably should stay in the typing.

Also update both 2 and 3 definitions to use Mapping[Any, Any], rather than Dict[Any, Any].
2019-11-04 08:10:45 -08:00
Jeremy Lainé 047caa9096 Add more stubs for cryptography (#3307) 2019-11-04 12:41:11 +01:00
Jon Dufresne 66c3945ca4 Remove certifi.old_where (#3436)
The function was removed from the API in commit (Nov 26, 2018):

https://github.com/certifi/python-certifi/commit/a462d21c3f491635ed11a6aaa4e2022d1ca4cace
2019-11-03 18:26:43 +01:00
Diego Elio Pettenò 7e27bf6bde Allow datetime() with a delta=timedelta() in assert(Not)AlmostEqual(s). (#3426)
While the documentation does not seem to make this particularly
obvious, it is allowed.
2019-11-02 22:35:09 -07:00
Jukka Lehtosalo 86135edb6d Fix signature of assertRaisesRegexp in unittest (#3434)
Fixes mypy false positive `"None" has noattribute "__enter__"` here:

```
class Foo(unittest.TestCase):
    def test_foo(self) -> None:
        with self.assertRaisesRegexp(Exception, "foo"):
            1 / 0
```

Fixes regression introduced in e6c467af82.
2019-11-01 15:48:35 +00:00
bianca rosa 4b8c6bbea1 add timespec arg to datetime.time.isoformat (#3432)
Close #3431
2019-11-01 11:25:15 +01:00
Diego Elio Pettenò 616cb0bb65 Add sock attribute for http.client.HTTPConnection in Python 3. (#3429)
The equivalent httplib.HTTPConnection class already include it for Python
2, despite the attribute not being documented for either version.
2019-10-30 23:21:50 +01:00
Jelle Zijlstra cd5cd12a35 asyncio: fix windows stubs (#3424) 2019-10-30 08:13:32 -07:00
Greg Ward 603458ba09 Fix some incorrect/incomplete annotations for redis.client.PubSub (#3408)
* redis: Fix return value declarations in redis.client.PubSub

get_message() was declared incorrectly. Start here:

  https://github.com/andymccurdy/redis-py/blob/3.3.11/redis/client.py#L3298-L3300

where it's obvious that get_message() returns either None or the
output of handle_message().

So what does handle_message() return? Combine:

  https://github.com/andymccurdy/redis-py/blob/3.3.11/redis/client.py#L3316-L3336
  https://github.com/andymccurdy/redis-py/blob/3.3.11/redis/client.py#L3366

and you can see it returns None or a dict mapping str to something.

* redis: Fix incorrect declaration for PubSub.get_message() argument

Docstrings says it's a float:

  https://github.com/andymccurdy/redis-py/blob/3.3.11/redis/client.py#L3293-L3295

And it eventually gets passed to settimeout() on a socket:

  https://github.com/andymccurdy/redis-py/blob/3.3.11/redis/connection.py#L182

* redis: Annotate one more method arg in PubSub class

get_message() and handle_message() are closely related:
ignore_subscribe_message does the same in both, and its default value
in both is False.
2019-10-30 07:33:00 -07:00
Sebastian Rittau c8405bb5d9 Add importlib.metadata (Python >= 3.8) (#3346)
Part of #3319
2019-10-29 19:53:47 -07:00
Rune Tynan b112c20dad Copyreg stubs (#3387) 2019-10-29 19:52:05 -07:00
Angela Ambroz b5b9a3959d Add pytz.FixedOffset (#3393) 2019-10-29 19:50:20 -07:00
Sebastian Rittau 5e9f66cb62 Add missing Python 3.7 and 3.8 annotations (#3399)
* Add explicit ssl_handshake_timeout arguments to open_connection and start_server

* Add context arguments to call methods

* Accept PathLike for create_unix_* paths

* Add TimerHandle.when()

Add missing version check

* AbstractServer is now an async context manager

* Add happy_eyeballs_delay and interleave arguments to create_connection

* Re-export asyncio.windows_events from asyncio

* Add name argument to Task constructor

* Add Task.get_coro()

* import and other fixes

* Fix return type of get_coro()
2019-10-29 19:49:37 -07:00
Sebastian Rittau 4770059894 Add missing ZipFile constructor arguments (#3414)
Closes: #3413
2019-10-29 19:46:31 -07:00
Dima Boger aae01b8de0 Add sort_keys param to all dump-like functions in PyYAML (yaml) lib (#3417) 2019-10-29 19:44:04 -07:00
Brett Cannon 5e051d8848 Clarify contributions are from people external to the project (#3421)
Closes #3420
2019-10-29 17:17:04 -07:00
Benjamin Peterson 2023394b37 exec, spawn: Allow bytes for environment keys and values. (#3419)
A more correct type would be Mapping[Union[bytes, str], Union[bytes, str]], but our hands are tied by the invariance of mapping keys.
2019-10-29 11:48:36 -07:00
Diego Elio Pettenò e6c467af82 Add missing expected_regex parameter to TestCase.assertRaisesRegexp(). (#3418)
This makes it match the signature of assertRaisesRegex() which is the modern name for the same function.
2019-10-29 16:16:53 +01:00
Taneli Hukkinen beaf306d12 Allow None for click.core.Context.default_map (#3416) 2019-10-29 00:10:27 +01:00
Anthony Sottile 9c724e9e60 Fix signature of multiprocessing.get_start_method (#3415) 2019-10-28 17:39:14 +01:00
Sebastian Rittau 87d7dd3d95 Fix annotations with literal values (#3411) 2019-10-28 06:59:28 -07:00
Michael Lee 6a7c2011cc Update sre_parse module for Python 3.8 (#3412)
It seems in Python 3.8, the 'Pattern' object in the (undocumented?)
sre_parse module was renamed to 'State', along with a few associated
parameters.
2019-10-28 08:08:49 +01:00
Utkarsh Gupta 72ff7b94e5 __init__.pyi: Accept RSAPrivateKey or RSAPublicKey as the key (#3410)
Closes: #3381
2019-10-26 21:09:06 +02:00
Alexander Schlarb 124111534a Add the memoryview.release method (#3405) 2019-10-25 14:29:44 +02:00
Ilaï Deutel bf944dbf94 Update stubs for tabulate (#3391) 2019-10-24 20:19:08 -07:00
Anthony Sottile 9feb21d029 Add werkzeug.exceptions.FailedDependency (#3403)
Available since werkzeug==0.15.0
2019-10-24 00:14:52 +02:00
Nikola Forró 92aa1ee9c2 logging.handlers: Add BufferingHandler.buffer (#3402)
Signed-off-by: Nikola Forró <nforro@redhat.com>
2019-10-23 14:33:06 +02:00
秋葉 ce8d1da5ce Add sys._debugmallocstats (#3401) 2019-10-23 14:31:43 +02:00
Vasily Zakharov 4f13e710c3 Added stub for urllib.proxy_bypass() (#3396) 2019-10-22 19:10:50 +02:00
Lawrence Chan f28691261a Change pprint depth type to Optional[int] (#3392) 2019-10-20 12:14:02 -07:00
Sebastian Rittau ec7960a8cb Convert namedtuples to class syntax (#3321) 2019-10-20 10:37:33 +02:00
Nikita Sobolev 2b9dc7b9c2 Adds posonlyargs property to arguments for python3.8+ (#3390) 2019-10-19 23:07:04 +02:00
Rebecca Chen 3fbebc78cb Require a more recent pytype version. (#3388)
Yesterday's release contains a number of pyi parser fixes, such as
support for the syntax in #3321.
2019-10-18 23:21:53 +02:00
Rebecca Chen ffd73b3e8e Add shlex.shlex.next in Python 2. (#3389)
shlex.shlex should match the Iterator protocol, for which it needs both
`__iter__` and `__next__` (`next` in Python 2) defined.
2019-10-18 23:13:38 +02:00
JR Heard bf862d9079 Add missing @property to Response.next() stub (#3384) 2019-10-18 10:23:15 +02:00
David Tucker 38fbdc9490 Fix show_default type in click.option signatures (#3385) 2019-10-18 10:22:02 +02:00
Eric N. Vander Weele 966f8d24e6 Revert __import__ function annotation to return type back to Any (#3383)
From python/mypy#7582.

This partially reverts back the change in
0ee7c3c38b to have `__import__` return
`Any` instead of `ModuleType`.
2019-10-18 00:10:41 +02:00
Jakub Stasiak fd7f1063d5 Change select() stub to accept iterables, not just sequences (#3382) 2019-10-17 21:30:14 +02:00
Nathaniel Brahms fa9e1ab445 multiprocessing.pool: Fix return of map_async() (#3378)
Closes #3377
2019-10-17 17:43:37 +02:00
Trim21 6b68fb04c9 pymysql.Cursor is a context manager (#3379) 2019-10-17 15:01:55 +02:00
Michael J. Sullivan 7c6104ddfe Don't shadow ast.Tuple with typing.Tuple (#3376) 2019-10-16 12:39:56 -07:00
Jakub Stasiak 6e4f6403ac Add PEP 593 (Annotated etc.) typing_extensions stubs (#3369)
The code has been added to typing_extensions in
https://github.com/python/typing/pull/632 and
https://github.com/python/typing/pull/639/.
2019-10-16 11:41:38 -07:00
Rune Tynan 6058c23136 Make path separator based on OS separator (#3375) 2019-10-16 10:12:45 -07:00
Sebastian Rittau 299d89ab76 generate_tokens(readline) must return bytes (#3372) 2019-10-16 08:55:23 -07:00
Rune Tynan 67629a14a7 Add stubs for cgitb (#3368) 2019-10-16 17:11:23 +02:00
cptpcrd 89f0f63502 Fix HTMLParser.handle_startendtag() attrs annotation (#3366)
The value can be None here as well as in handle_starttag().
2019-10-15 14:42:25 +02:00
Sebastian Rittau b969ead0ce Reorder memoryview.__setitem__ overloads (#3365)
Necessary for python/mypy#7717
2019-10-15 14:14:48 +02:00
Rune Tynan dfe68625ec Add public missing asyncio stubs for windows and proactor files (#3234)
* Add public missing asyncio stubs for windows and proactor files, and any necessary private return/argument types.

* Add methods to BaseProactorEventLoop that mypy is complaining about, with note about status at runtime

* Add asyncio constants file
2019-10-14 21:03:29 -07:00
Rune Tynan 6c42f6bb2f Add bdb stubs (#3354) 2019-10-14 20:01:24 -07:00
Benjamin Peterson add16d2715 protobuf: Fix inadvertently deleted annotations. (#3364)
* protobuf: Fix inadvertantly deleted annotations.

* Run black on protobuf.
2019-10-14 13:41:58 -07:00
Árni Már Jónsson 7e99848b2c fixing https://github.com/python/typeshed/issues/3361 (#3362)
Fixes #3361
2019-10-14 15:21:00 +02:00
Sebastian Rittau 6b55f5c498 Clean up multiprocessing + shared_memory (#3351)
* Make multiprocessing stubs match implementation

* Add multiprocessing.process.BaseProcess
* Use BaseProcess in multiprocessing.context where applicable
* Remove non-existing BaseContext.Process()
* Derive DefaultContext from BaseContext
* Fix BaseContext/DefaultContext.set_start_method() signatures
* Re-export multiprocessing.context.Process from multiprocessing,
  instead of using a custom definition
* Re-export multiprocessing.active_from from multiprocessing.process
  instead of using a custom definition

* Add parent_process() (Python 3.8)

* Complete BaseManager; add Server

* Add multiprocessing.shared_memory et al
2019-10-14 09:54:45 +02:00
Sebastian Rittau 0501e2b329 Annotations for remaining Python 3.8 additions (#3358)
* Add os.add_dll_directory()
* Add memfd_create() and flags
* Add type annotation to flags
* Add stat_result.st_reparse_tag and flags
* Add ncurses_version
* Add Path.link_to()
* Add Picker.reducer_override()
* Add plistlib.UID
* Add has_dualstack_ipv6() and create_server()
* Add shlex.join()
* Add SSL methods and fields
* Add Python 3.8 statistics functions and classes
* Remove obsolete sys.subversion
* Add sys.unraisablehook
* Add threading.excepthook
* Add get_native_id() and Thread.native_id
* Add Python 3.8 tkinter methods
* Add CLOCK_UPTIME_RAW
* Add SupportsIndex
* Add typing.get_origin() and get_args()
* Add unicodedata.is_normalized
* Add unittest.mock.AsyncMock

Currently this is just an alias for Any like Mock and MagicMock. All of
these classes should probably be sub-classing Any and add their own
methods. See also #3224.

* Add unittest cleanup methods
* Add IsolatedAsyncioTestCase
* Add ElementTree.canonicalize() and C14NWriterTarget
* cProfile.Profile can be used as a context manager
* Add asyncio task name handling
* mmap.flush() now always returns None
* Add posonlyargcount to CodeType
2019-10-14 09:53:48 +02:00
Sebastian Rittau 6507875f28 Annotate Python 3.8 removals (#3359)
* macpath
* time.clock()
* Some cgi functions
* XMLParser(html) and doctype()
* unicode_internal
* Two sqlite3 classes hidden
* fileinput bufsize arg
* Treeview.selection no longer takes arguments
2019-10-14 09:51:39 +02:00
Sebastian Rittau 950f391704 Remove unnecessary __all__ annotations (#3357) 2019-10-13 16:22:03 -07:00
Sebastian Rittau de26a3d109 Remove raise statements from function bodies (#3355)
While it may eventually be useful to mark the exceptions that can be
raised from a function or method, the semantics are currently undefined
and unclear.
2019-10-13 21:51:43 +02:00
秋葉 2bd1b75641 Extract asyncio exceptions into a separate module (Python 3.8) (#3356) 2019-10-13 12:20:02 +02:00
Utkarsh Gupta 91b72d49c7 typing.pyi: Remove verbose and rename from NamedTuple (#3352)
Closes #3235
2019-10-12 21:27:50 +02:00
Sebastian Rittau 62bbdf856c Add several Python 3.8 annotations (#3347) 2019-10-12 19:36:56 +02:00
Guido van Rossum 8ec25708d9 Update 'format' README section -- don't imply it is executable (#3350) 2019-10-12 19:18:34 +02:00
Sebastian Rittau 583784d94c Add missing exception to smtplib (#3348)
Improve a few other types
2019-10-12 19:15:44 +02:00
Rune Tynan 6354bc8a10 Ensurepip stubs (#3349) 2019-10-12 02:45:43 +02:00
Sebastian Rittau 61d5f76a1d find_loader() can return None (#3341) 2019-10-11 10:48:48 -07:00
Maarten ter Huurne 6a92ae6295 Change type for urllib headers from Mapping to email.message.Message (#3345)
Also remove override of 'headers' in HTTPError

Closes #3344
2019-10-11 14:56:19 +02:00
Florian Bruhin bb12f3bdea Fix argument type for logging.Formatter.formatTime (#3343)
datefmt can be None - that's what the default value is: https://docs.python.org/3/library/logging.html#logging.Formatter.formatTime
2019-10-11 14:39:24 +02:00
Benjamin Peterson 036abc7fda protobuf: Narrow type of Message.FromString. (#3340)
Remove unnecessary definitions in sub-classes.
2019-10-11 08:28:28 +02:00
Florian Bruhin 9b0922166a Allow callables in _SourceObjectType (Python 2) (#3338)
This is important because mypy doesn't generally think functions are compatible with `FunctionType`, so `inspect.getsource` on arbitrary functions is rejected by the current annotations.
2019-10-10 20:51:56 -07:00
Sebastian Rittau d41bcd39e1 Add assorted annotations (#3335)
* Add assorted annotations

* Fix type of Purpose items
2019-10-10 20:51:49 -07:00
Sebastian Rittau 8a7d61741d Python3.8 additions and changes (#3337)
* Add as_integer_ratio() to a few types

* Add dirs_exist_ok to copytree()

* int, float, complex accept __index__ args

Also fix complex.__init__ argument names

* Add __reversed__ to dict et al.

* Python 3.8 date(time) arithmetic fixes

* Add CodeType.replace()
2019-10-10 20:51:27 -07:00
Martin DeMello d0beab9b8e Fix an argument to csv.DictReader() (#3339)
From the Lib/csv.py source, 'f' is passed directly to _csv.reader, which
expects Iterable[Text]
2019-10-10 20:13:20 -07:00
Benjamin Peterson fc23c8274f protobuf: Tighten annotations for MergeFromString and ParseFromString. (#3333) 2019-10-10 18:07:53 +02:00
Jukka Lehtosalo eca93753ee Update the signature of decorator.decorator (#3336)
Nothing prevents a decorator defined using `@decorator` from
changing the signature of the decorated function. For example,
this example changes the return type to `str`:

```
from decorator import decorator

@decorator
def stringify(f, *args, **kwargs) -> str:
    return str(f(*args, **kwargs))
```

The old signature caused false positives in internal Dropbox code.

I couldn't come up with a signature that would produce better types
with mypy while not generating false positives.
2019-10-10 16:45:06 +01:00
Utkarsh Gupta 1a932ce26a message.pyi: Change HeaderType to Any (#2924)
Fixes #2863
2019-10-10 12:24:44 +02:00
Vasily Zakharov 57384ce033 Revised stubs for geoip2 third party library (#3317) 2019-10-09 19:28:42 -07:00
Russ Allbery f0ccb325aa Mark some urllib.parse return fields optional (#3332)
Per the urllib.parse documentation, username, password, hostname,
and port will be set to None if not set in the parsed URL.  The
same is true for urlparse in Python 2 according to its documentation.
2019-10-09 19:38:59 +02:00
Sebastian Rittau 07c8675ba5 Remove unused # type: ignore comments (#3325) 2019-10-09 10:27:18 -07:00
Utkarsh Gupta bd7222c396 models.pyi: Add missing requests.Respons.next() (#3328)
Closes: #3207
2019-10-09 19:01:30 +02:00
Jukka Lehtosalo 3a2fdfd45d Make it explicit that the cryptography stubs are incomplete (#3331) 2019-10-09 16:20:36 +01:00
Jukka Lehtosalo 0914d50b49 Fix the signature of decorator.contextmanager (#3330) 2019-10-09 16:58:37 +02:00
wouter bolsterlee 824e94a933 Make 2-arg iter() retrun type match passed callable's return type (#3326)
This is a continuation of #3291, which was the initial fix for #3201.

The 2-arg version of iter() turns a callable into an iterator. The
changes made in #3291 introduce an Any return type for both the
callable's return type and the iterator's type, while in reality the
return type of the function is always the same as the iterator's type.
2019-10-09 08:44:41 +02:00
robertschweizer 3ee8fc2242 Add missing Optional types in urllib.parse (#3263)
None values are accepted, and interpreted as empty (byte) strings by
some urllib.parse functions.
2019-10-09 08:38:46 +02:00
Benjamin Peterson 50961d45a1 protobuf: Add Message.FromString static method. (#3327) 2019-10-09 07:59:07 +02:00
Utkarsh Gupta 4027add6b3 __init__.pyi: Add missing methods on pkg_resources.VersionConflict (#3318) 2019-10-08 20:36:38 +02:00
Sebastian Rittau d82d3396e7 Minor flake8 improvements (#3324)
* Update flake8-bugbear
* Remove unnecessary comment
* Add a comment about an upcoming fix
2019-10-08 17:42:36 +02:00
Sebastian Rittau 256b3ce8ab Remove a bunch of unused imports (#3323) 2019-10-08 07:59:32 -07:00
Lukáš Lalinský a6f146e651 Fix return type of werkzeug's ProxyFix (#3320) 2019-10-08 10:30:00 +02:00
Rafi Blecher 6e4708ebf3 Add type stub for decorator lib (#3038) 2019-10-07 22:21:31 +02:00
Rune Tynan 7710e925ca Add data to UserList class, fix UserDict.data type (#3316) 2019-10-07 17:05:19 +02:00
Utkarsh Gupta 447691cf46 imaplib.pyi: Add missing imaplib.IMAP4.enable() (#3314)
Closes: #3313
2019-10-06 19:48:48 -07:00
Utkarsh Gupta 717cd1f96f imaplib.pyi: Add ssl_context parameter for Python >= 3.3 (#3310)
Fixes: #3289
2019-10-06 18:57:22 +02:00
Ryan Morshead b9342eca0a add IncrementalNewlineDecoder constructor (#3311) 2019-10-06 17:22:03 +02:00
Ryan Morshead 3743b64b07 IncrementalNewlineDecoder.decode accepts str (#3312)
The decode method of IncrementalNewlineDecoder accepts a string when its decoder is None.
2019-10-06 11:33:26 +02:00
Utkarsh Gupta 79a8f0b8c6 imaplib.pyi: Take strings as args instead of a list of strings (#3308)
Fixes: #3289
2019-10-04 20:10:21 -07:00
sinancepel cd418e9546 introduce __floor__ and __ceil__ for int in Python 3 (#3306) 2019-10-04 19:16:32 -07:00
Glyph 83589844c9 rrule.weekday(...) returns rrule.weekdays, not _common.weekdays. (#3274) 2019-10-05 01:49:49 +02:00
Rebecca Chen 90aa27b54a Fix the signature of IOBase._checkClosed(). (#3305)
* In Python 2, the optional `msg` argument was missing.
* In Python 3, the method was missing altogether.

Reference:
https://github.com/python/cpython/blob/2.7/Lib/_pyio.py#L423
https://github.com/python/cpython/blob/3.6/Lib/_pyio.py#L443
2019-10-04 14:53:48 -07:00
Sebastian Rittau 0a426d8a8e Move cryptography from 2 to 2and3 (#3304)
The cryptography stubs are very rudimentary at the moment, but there
is nothing that limits them to just Python 2.

Closes: #3303
2019-10-04 14:11:42 -07:00
Jeremy Lainé 41d23a67f6 ssl: add VerifyFlags flags and VerifyMode enum (#3302)
Closes #3301
2019-10-04 16:27:30 +02:00
Vasily Zakharov e62857f851 Updated maxminddb stubs to v1.5.0 (#3300) 2019-10-04 12:55:46 +02:00
Utkarsh Gupta fa571fb224 builtins.pyi: Use two type vars (#3291)
Fixes: #3201
2019-10-04 00:15:41 +02:00
Benjamin Peterson 9a1d205f34 cryptography: Return RSAPrivateKeyWithSerialization from generate_private_key. (#3296)
The only extant implementation of generate_private_key returns this more specialized interface.
2019-10-03 01:09:25 +02:00
Jelle Zijlstra c38cf6736e Allow callables in _SourceObjectType (#3295)
This is important because mypy doesn't generally think functions are compatible with `FunctionType`, so `inspect.getsource` on arbitrary functions is rejected by the current annotations.
2019-10-03 00:52:21 +02:00
Michael J. Sullivan eeb8daa467 Remove some spurious version checks in logging (#3292)
PR #3269 added some version checks for the argument type to setLevel
and the existence of NullHandler. While these features weren't present
in early versions of Python 3, they *are* present in Python 2.7, which
leads to false positives.
2019-10-02 08:09:21 +02:00
Michael J. Sullivan 455f25a5c7 Use Any instead of object in the view types for __and__ and __sub__ (#3294)
This was discussed in #3181 and the correct explanation was given that
object ought to be preferred here. In practice this caused an obscure
issue with mypy when using this operations on the results of
six.viewkeys(), since it decided that it wanted a mapping *from* object
as a result of inference contexts. Grumble.
2019-10-02 08:03:57 +02:00
Michael J. Sullivan ad881f94d7 Add the mypyc_attr function to mypy_extensions (#3290) 2019-10-01 17:45:47 -07:00
Stefan T 0abb50e20a Add http.MISDIRECTED_REQUEST introduced in 3.7 (#3293) 2019-10-01 15:42:44 -07:00
Sebastian Rittau c32e1e2280 Enable --disallow-any-generics for stubs (#3288) 2019-10-01 05:31:34 -07:00
Benjamin Peterson 23b353303b Allow passing bytes and byte string to yaml load APIs. (#3287) 2019-09-30 22:30:28 +02:00
Vasily Zakharov 785d7838e1 Added stub for asyncore.socket_map, undocumented but useful (#3284) 2019-09-30 20:51:11 +02:00
Vasily Zakharov a2834cf24d Added stub for http.server.BaseHTTPRequestHandler useful undocumented fields (#3285) 2019-09-30 19:27:54 +02:00
Vasily Zakharov aaff561ef6 Added stub for urllib.request.proxy_bypass() (#3283) 2019-09-30 18:57:14 +02:00
Vasily Zakharov c441a1f5b8 Added ConfigParser.BOOLEAN_STATES # Undocumented (#3281) 2019-09-30 17:10:48 +02:00
Sebastian Rittau ed4b1de0ad Fix third_party errors with --disallow-any-generics (#3278)
Part of #3267. Together with #3276 this should fix all such problems.
2019-09-30 13:14:01 +02:00
Brad 412b9e74d5 Change last asyncio.gather() overload ret. to List (#3248)
Stems from PR #1550/ Issue #3243.
2019-09-30 12:42:58 +02:00
Eric Traut 468d13a205 Modified __add__ method in tuple class (#3252)
Modified __add__ method in tuple class to allow it to accept tuples with different generic parameter types. This allows, for example:
a = (1, )
b = a + (2.4, )
2019-09-30 12:42:40 +02:00
Sebastian Rittau 23232c056c Simplify Travis-CI configuration (#3220)
This removes the indirection of setting environment variables to
install and run tests. Also, use an explicit version for running
mypy with typed-ast.
2019-09-30 11:46:12 +02:00
Guido van Rossum 95185fa9cf Improve the explanatory comment at the top of check_consistent.py 2019-09-29 09:23:11 -07:00
Guido van Rossum b336182b69 Fix some errors with --disallow-any-generics (#3276)
See #3267. Covers all of stdlib/2and3.
2019-09-29 09:15:27 -07:00
hh-h 1e881ad156 switched return_exceptions from bool to Literal for asyncio.gather (#3275) 2019-09-29 16:46:37 +02:00
Alan Du d4727c39f1 Add multiprocessing.Array (#3272) 2019-09-29 16:30:09 +02:00
Anthony Sottile c0371df172 dir argument to tempfile functions may take PathLike (#3226) 2019-09-29 16:09:22 +02:00
Andrew Svetlov 60bdf60eda Add missing default for ssl_handshake_timeout agrument (#3277) 2019-09-29 15:13:09 +02:00
Rebecca Chen ac35a18ad6 Make the value argument to ctypes.cbool.__init__ optional. (#3273) 2019-09-28 00:39:04 +02:00
Parth Sharma 4e1a45a0bb update codecs.register type definition (#3271)
Closes #3262
2019-09-27 19:06:08 +02:00
brianjyoung d1ed2b275f Updated logging type stub (#3269) 2019-09-27 13:28:08 +02:00
Alex Jurkiewicz efdbefee86 Add return types for pymysql.connection.close/cursor (#3268) 2019-09-27 07:04:23 +02:00
Árni Már Jónsson e0cc8bdafb inspect.Traceback/FrameInfo index/code_context attributes now Optional[] (#3265)
Resolves #3264
2019-09-26 17:13:00 +02:00
Colin Gilgenbach c33239b011 click: Support tuples of _ParamTypes, CliRunner fixes (#3259) 2019-09-24 14:11:25 +02:00
Rebecca Chen 3f8c2169d1 Define listdir in posix and import it in os. (#3258) 2019-09-23 23:41:05 +02:00
Augusto Hack 829c646d69 Added constructor types for click.FloatRange (#3257) 2019-09-23 20:40:54 +02:00
Augusto Hack c1ec292344 Added missing top-level export to click (#3256) 2019-09-23 18:48:13 +02:00
sinancepel 01b7002a89 Introduce explicit __str__ and __repr__ for Exceptions (#3247) 2019-09-23 18:25:49 +02:00
Eric Traut c879ff05aa Changed type of fieldname parameter in DictWriter __init__ method from Sequence[str] to Iterable[str]. This allows it to work with the following code: (#3253) 2019-09-23 18:24:45 +02:00
秋葉 a011d1945e add missing errnos (#3254) 2019-09-23 18:24:05 +02:00
Eric Traut c65b5cc61c Changed combine method in datetime to use aliased _date and _time types (like all other methods in this class) to avoid namespace collision with date and time methods. (#3251) 2019-09-23 18:23:46 +02:00
Vasily Zakharov 4d662f0f49 Stubs for maxminddb added (#3245) 2019-09-19 17:49:38 +02:00
Rebecca Chen 0602840cc2 Make the type of timeout Optional[float] everywhere in subprocess. (#3241) 2019-09-18 11:05:49 +02:00
Rebecca Chen 9488b58fb3 Copy a better definition of abstractmethod from 3/abc to 2/abc. (#3242) 2019-09-18 11:04:53 +02:00
Carl Meyer 8b28753b64 Update and improve py_compile module stubs. (#3240) 2019-09-17 19:48:26 -07:00
Philippe F ce0dc8a23d Add proper support for __rtruediv__ on libpath.Path (#3236) 2019-09-17 23:24:42 +02:00
Augusto Hack 4c63939585 setprofile accepts None (#3239)
The function `threading.setprofile` can be called with a `None` value to
clear the profile function. This does unset the function from the
existing threads, it only clears the callback function so that new
threads are created without the profiling hook installed.
2019-09-17 13:15:27 +02:00
Brad babc0c1912 Accept bytes to several Redis client commands (#3238) 2019-09-17 11:30:00 +02:00
Alex Garbutt 895ae0fd9b requests.Session.request data arg accepts an iterable of tuples (#3237) 2019-09-16 22:16:52 +02:00
Ivan Levkivskyi d0f3eb2d6b Use Text for text arguments to click.[un]style (#3233) 2019-09-16 15:36:28 +02:00
秋葉 2edb36e993 Add ThreadingHTTPServer stub (#3232)
Fixes #3217
2019-09-15 16:06:19 +02:00
Rune Tynan 2b97bb904a Add AIFC module stubs (#3075) 2019-09-11 15:39:41 -07:00
plokmijnuhby 8d053f139f Change SyncManager behaviour when used as a context decorator (#3230)
Resolves #3018.
2019-09-11 18:24:36 +02:00
秋葉 5ccf017ca0 fix: Add MapResult type (#3228) 2019-09-11 18:20:40 +02:00
jjmortensen 686e21d330 Fix type in argparse.HelpFormatter._fill_text() (#3229) 2019-09-11 17:00:25 +02:00
Sebastian Rittau c9f19b1d72 Use protocol for FTP.stor* (#3227)
* Use protocol for FTP.stor*

* Reformat ftplib.pyi with black
2019-09-10 14:40:10 -07:00
herr kaste 668988fa8c Return concrete sets from ItemsView and KeysView (#3181) 2019-09-05 16:59:59 +02:00
Benjamin Peterson 3fc8aec425 Allow passing str to Python 2's bytearray.extend. (#3223) 2019-09-04 23:24:58 +02:00
Sebastian Rittau efb4af0108 Mark some types as non-hashable (#3219)
Based on @JelleZijlstra's PR #2221.

Fixes #2148
2019-09-04 17:38:09 +02:00
Daniel Holth 1d21315773 ssl.pyi: Add functions, support Path (#3044) 2019-09-03 12:10:48 +02:00
Pascal Corpet b94fa842eb Type response of Flask test client methods: get, post, etc. (#2904) 2019-09-03 11:12:11 +02:00
Rebecca Chen abc241bd35 Use Literal to improve tempfile.[Named]TemporaryFile. (#3215) 2019-08-31 11:25:44 +02:00
Shannon Zhu f9300ed1ed Update pyre_extensions stub (#3214) 2019-08-30 16:15:24 -07:00
Colin Gilgenbach 99e8ed42a4 Mark ParamType.fail() as NoReturn (#3213)
This function just raises a click.BadParameter exception with the supplied arguments.
2019-08-29 17:57:43 +02:00
Sebastian Rittau ae881faaf1 Remove custom _Text type (#3211)
* Remove custom _Text type

Since the custom type was only used in argument types, it was
effectively only an alias for typing.Text.

* Run requests/api.pyi through black
2019-08-29 08:51:59 -07:00
Andriy Teraz d78747c0f0 Make target optional in contextlib redirecting managers (#3212)
Fixes #3210
2019-08-29 17:38:53 +02:00
Benjamin Peterson f53f52de57 requests: Allow bytes for url parameters. (#3209)
typeshed already partially reflected https://github.com/psf/requests/pull/2238 but not completely.
2019-08-28 21:53:19 -07:00
Benjamin Peterson a48abb4546 Add unquote_to_bytes to Python 3 six.moves.urllib.parse. (#3208) 2019-08-28 18:01:38 -07:00
Jaromir Latal cd1a0c592a Add typestubs for unittest.util (#3186) 2019-08-27 15:34:22 +02:00
Ran Benita 3e4a251b2b doctest: fix type of DocTestParser.get_doctest(lineno) (#3206)
Reference:
https://docs.python.org/3/library/doctest.html#doctest.DocTest.lineno

Also noticed a typo in get_examples() argument name.
2019-08-24 13:30:13 -07:00
plokmijnuhby 282405696e Make inplace sorting require mutable sequences in bisect module (#3199) 2019-08-24 09:06:38 -07:00
Rebecca Chen 03b38d4d2e Add sys.flags.utf8_mode. (#3205)
This is new in Python 3.7:
https://docs.python.org/3/library/sys.html#sys.flags
2019-08-23 12:06:21 -07:00
Benjamin Peterson ce0f5b226f zipfile.ZipFile: Add start_dir attribute. (#3203) 2019-08-23 08:46:16 +02:00
Scott Belden 04bcb89aea create_server returns a Server, not AbstractServer (#3131)
* remove create_unix_connection and use ABCMeta
2019-08-23 08:31:40 +02:00
Samuel Freilich 75ccbdcab5 cadata param can (and PEM-encoded cadata must) be unicode under PY2 (#3150) 2019-08-23 08:25:41 +02:00
Shannon Zhu 72010bc5dc Update how mock classes alias to Any (#3182)
* Update how mock classes alias to Any

> First, the z: Any situation looks like a bug or accidental feature to me.
This is definitely meant (and works) as a variable declaration; that it
also allows using z as a type seems wrong. I can't find any evidence in
PEP 484 that this was intended; in mypy it's likely the accidental result
of other design choices meant to shut up errors about Any.

Ideally these classes could be declared as empty class stubs, but since the comments suggest this isn't possible yet, let's update these to be type aliases to Any rather than global variables of type Any. This would avoid invalid type errors when the implementation of type checkers respect the intention that `z: Any` does not make `z` a valid type.

* Update mock.pyi
2019-08-19 17:10:27 -07:00
Michael Nix 1ab5145124 adds threading related members to queue.pyi (#3198) 2019-08-19 18:33:19 +02:00
Alan Du e252094354 multiprocessing.Value can also take a Type (#3200) 2019-08-19 17:52:00 +02:00
Bouteillebleu d5a918de7b Add stubs for CGIHTTPServer (#3196)
This commit adds:
* Stubs for CGIHTTPServer in the Python 2 standard library, as requested in #1147.
* Stubs for six.moves.CGIHTTPServer in Python 2, as requested in #22.
2019-08-19 15:34:29 +02:00
Ran Benita b2cd972b17 builtins: int.__pow__ can take a modulo argument (#3192)
See:
https://docs.python.org/3/reference/datamodel.html#object.__pow__
https://docs.python.org/3/library/functions.html#pow
2019-08-17 07:23:53 -07:00
Ran Benita c7417e8b3f builtins,numbers: harmonize float.__round__ and Real.__round__ (#3193)
See:
https://docs.python.org/3/reference/datamodel.html#object.__round__
https://docs.python.org/3/library/functions.html#round
2019-08-17 07:23:04 -07:00
Ran Benita c0625d3280 builtins: add __trunc__ to int and float (#3194)
See:
https://docs.python.org/3/reference/datamodel.html#object.__trunc__

It also works on Python 2.7.
2019-08-17 07:22:03 -07:00
Rebecca Chen fab2ee0d7c Remove unnecessary quotes around forward references. (#3191) 2019-08-16 20:29:32 -07:00
Michael Lee b294782183 Make most contextmanager __exit__ signatures return Optional[bool] (#3179)
This pull request is a follow-up to https://github.com/python/mypy/issues/7214.

In short, within that mypy issue, we found it would be helpful to
determine between contextmanagers that can "swallow" exceptions vs ones
that can't. This helps prevent some false positive when using flags that
analyze control flow such as `--warn-unreachable`. To do this,
Jelle proposed assuming that only contextmanagers where the `__exit__`
returns `bool` are assumed to swallow exceptions.

This unfortunately required the following typeshed changes:

1. The typing.IO, threading.Lock, and concurrent.futures.Executor
   were all modified so `__exit__` returns `Optional[None]` instead
   of None -- along with all of their subclasses.

   I believe these three types are meant to be subclassed, so I felt
   picking the more general type was correct.

2. There were also a few concrete types (e.g. see socketserver,
   subprocess, ftplib...) that I modified to return `None` -- I checked
   the source code, and these all seem to return None (and don't appear
   to be meant to be subclassable).

3. contextlib.suppress was changed to return bool. I also double-checked
   the unittest modules and modified a subset of those contextmanagers,
   leaving ones like `_AssertRaisesContext` alone.
2019-08-16 16:13:33 -07:00
Ivan Levkivskyi 3cfc3150f0 Partially restore old (imprecise) signature of Match.group() (#3190)
This partially reverts #3172
2019-08-16 19:53:52 +01:00
Niels Buwen 5638d29203 Fix #3187 : Wrong Signatures in socketserver (#3189)
Fixes #3187
2019-08-16 17:08:23 +02:00
Jon Dufresne 0ee7c3c38b Update __import__ function annotations (#3188)
Per the docs, globals/locals is an optional argument.
Additionally, globals/locals can be any mapping type, not only a dict.
Likewise, fromlist can be any sequence (the docs mention a tuple, not a
list).
The function returns a ModuleType, not Any.
2019-08-16 11:03:00 +02:00
Rebecca Chen b873894e16 Fix a typo (self -> cls) in stdlib/2/subprocess.pyi. (#3185) 2019-08-14 18:14:30 -07:00
Ville Skyttä 1edd6cd8a8 Add Match.regs (#2819) 2019-08-10 20:21:54 -07:00
Jon Dufresne 679e1a9a8c Update URL: python/black → psf/black (#3180) 2019-08-10 13:31:58 -07:00
Rune Tynan 15b7cdaf40 Implement ZipExtFile in the zipfile type stubs (#3074) 2019-08-10 13:25:03 -07:00
Patrick Valsecchi 26f575130c Add some redis types (#3092) 2019-08-10 13:22:40 -07:00
Benjamin Peterson baea5a7bc3 Widen the annotation of os.write to include buffer. (#3109) 2019-08-10 13:15:46 -07:00
Benjamin Peterson 0dc3bf941a Improve type of tornado.testing.gen_test. (#3174)
gen_test can accept a timeout parameter. See https://www.tornadoweb.org/en/branch5.1/testing.html#tornado.testing.gen_test.
2019-08-10 13:08:59 -07:00
Sebastian Rittau 628eee29f7 Use Literal in a few more places (#3176) 2019-08-10 13:08:18 -07:00
Sebastian Rittau c579f91077 Improve werkzeug exceptions slightly (#3178)
* Use Text for HTTPException.description
* Add Unauthorized.www_authenticate
* Remove wrong get_headers() overrides
2019-08-09 20:05:56 +02:00
Sebastian Rittau 3f6cec9872 Fix Match.group problems (#3172)
* group() may return None values
* group() allows to mix int and str arguments
* Use concrete return type
* Merge overloads
2019-08-08 16:59:20 +02:00
Rebecca Chen 6f01493edc Move some constants from tokenize to token in Python 3.7+. (#3175) 2019-08-08 08:45:08 +02:00
Evgeny Dedov 0dea39cb3c make basicConfig parameters Optional[...] (#3170) 2019-08-07 10:43:05 +02:00
g.denis 50f1988650 concurrent: add private classes and exceptions (#3169) 2019-08-07 10:39:15 +02:00
Cole Maclean 29771aa1ee Add missing methods to asyncio stubs (#3088) 2019-08-06 08:34:38 +02:00
Jelle Zijlstra d05a9d3d83 Improve enums (#3168)
I realized while working on srittau/type-stub-pep#64 that a
few things we do in existing enum definitions in typeshed are
problematic:

- Using "= ..." doesn't allow type checkers to correctly type the
  result of Enum.MEMBER.value. In fact, mypy at least infers
  .value to be "Ellipsis" if you do this.
- Properties on the enum values themselves, like HTTPStatus.phrase,
  should not be specified directly as attributes, because it makes
  type checkers think that the properties themselves are enum
  members.

I ended up doing a bit more cleanup to the signal module:
- Remove unnecessary ... initializers.
- Remove unnecessary _SIG = Signals alias.
- I don't have Windows to test, but the C code for _signal suggests
  that CTRL_C_EVENT and CTRL_BREAK events are not Signals, but just ints:
  https://github.com/python/cpython/blob/1dbd084f1f68d7293718b663df675cfbd0c65712/Modules/signalmodule.c#L1575
2019-08-05 08:08:57 -07:00
Phil Jones 1dc24e1c67 Add nbytes to the memoryview definition (#3167)
`nbytes`, like `contiguous`, was added in Python 3.3.
2019-08-03 07:51:55 -07:00
Nicklas Lindgren 3c4141982e Declare asyncio.as_completed() as taking an Iterable (#3164)
The stub for asyncio.as_completed declared it as taking a Sequence of
Futures. This was unnecessarily strict.

Just like asyncio.wait, asyncio.as_completed can be declared to take
an Iterable of Futures instead. Both these functions iterate over
their argument only once to store its items in a set, so an Iterable
is sufficiently strict. This has been true since the initial
implementation of the functions.
2019-07-31 10:53:23 -07:00
Jon Dufresne 02401c836f Add type annotations for Python 3 html.entities (#3161) 2019-07-31 15:46:16 +02:00
Jon Dufresne f2fdb54765 Precise the type of Python 2 htmlentitydefs module (#3163)
The code and documentation specifies the values specifically as
dictionaries.
2019-07-31 15:45:50 +02:00
Jon Dufresne edee7cfb3c Remove unused import from stdlib/2/htmlentitydefs.pyi (#3162) 2019-07-31 09:06:02 +02:00
Ilya Konstantinov 4c8d577d68 flask: allow view func body to be dict (#3149) 2019-07-31 02:04:36 +02:00
Rebecca Chen c3b70d4224 Require the newest pytype version, with a pyi parser fix. (#3160)
For https://github.com/python/typeshed/pull/3149.
2019-07-30 13:50:51 -07:00
Anthony Sottile 29dde6c883 Fix type annotations for get_wch / unget_wch (#3157) 2019-07-30 17:57:11 +02:00
Ville Skyttä c6cbe4da66 inspect: use more specific arg type for some source retrieve functions (#3155) 2019-07-30 17:53:56 +02:00
Brad bd2d0fcc85 Add hints for 3 globals from logging/__init__.py (#3159) 2019-07-30 17:28:13 +02:00
Anthony Sottile 32a89809f0 curses: getch returns an integer (#3156) 2019-07-30 09:25:01 +02:00
Michael R. Shannon 568f1ea555 Add attributes to xml.etree.ElementTree.ParseError. (#3158) 2019-07-30 08:48:28 +02:00
Allison Kaptur 15aa18d0a2 dateutil.rrule can take dates (#3154) 2019-07-27 11:39:23 +02:00
Sebastian Rittau 9ccf9356bf Remove Python 3.4 support (#3147)
Closes #3123
2019-07-27 10:58:21 +02:00
Kamil Bar 4697adcb1a [stdlib][3] Add missing typing.OrderedDict generic stub for Python 3.7.2 (#3153) 2019-07-26 20:46:15 +02:00
Ran Benita c8e7d98c1f Allow function.__code__ in Python 2 (#3152)
The following code works:

    >>> print(sys.version)
    2.7.16 (default, Mar 11 2019, 18:59:25)
    >>> def f(): pass
    >>> print(f.__code__)
    <code object f at 0x7f8534ecc8a0, file "<stdin>", line 1>
    >>> isinstance(f.__code__, types.CodeType)
    True

but it didn't type-check with `mypy --python-version 2.7`.
2019-07-26 07:40:22 -07:00
Rebecca Chen c356316c6f Use pytype.config.Options.create() for prettier code. (#3151)
This is a small cosmetic change. I want to encourage use of the
nicer-lookng pytype.config.Options.create() rather than
direct construction of the command-line args, so I'm changing
over all occurrences of the latter that I can find.
2019-07-25 19:43:33 -07:00
Connor Brinton df8ecf5a67 Fix incorrectly named parameters in logging module (#3148) 2019-07-25 21:29:55 +02:00
Vasily Zakharov e9d1f86591 gettext stubs fixed (#3130) 2019-07-25 16:57:14 +02:00
Sebastian Rittau b20e5b6c14 Travis: run mypy with Python 3.8 as well (#3146)
This runs mypy both with Python 3.7 and 3.8. In Python 3.8,
mypy switched from using typed-ast to using Python's built-in ast.
This patch ensures that both are tested.
2019-07-25 07:43:52 -07:00
Maarten ter Huurne 32ee49c79c Add zipfile.ZipFile.filename (#3104) 2019-07-25 11:26:39 +02:00
Ran Benita c9f9530224 xml.etree.ElementTree: use literal type for a more precise return value for tostring() (#3120) 2019-07-25 09:31:12 +02:00
Michael J. Sullivan b3f7be523a Fix __call__ type for GeneratorContextManager (#3143) 2019-07-24 22:20:15 +02:00
Ville Skyttä bf50612d76 inspect: get{doc,comments,module,sourcefile} can return None (#3137) 2019-07-24 22:05:01 +02:00
Ran Benita 9a7b286c66 warnings: ignore the type of category when message is a Warning (#3121) 2019-07-24 21:46:23 +02:00
Sebastian Rittau 0177dedc42 Add werkzeug.middleware (#3103)
HTTPConnection.timeout can be a float
2019-07-24 08:51:55 -07:00
Zsolt Dollenstein 8794e40d41 Fix ast.Constant availability (#3142) 2019-07-24 14:10:51 +02:00
Ville Skyttä 322be1b9e7 Upgrade flake8* and isort versions (#3141) 2019-07-23 23:02:19 +02:00
Ville Skyttä 8e0d288ea4 json: require a JSONDecoder/JSONEncoder in cls (#3138) 2019-07-23 22:59:57 +02:00
Nipunn Koorapati 67d091db15 Update google RepeatedCompositeFieldContainer (#3136) 2019-07-22 09:00:22 +02:00
Daniel Hahler 9dcdc7d481 faulthandler.dump_traceback_later: timeout can be float (#3134) 2019-07-21 01:04:25 +02:00
Naman 9379cedfa7 remove itertools.accumulate from Python 2 stubs (#3135) 2019-07-19 22:31:32 -07:00
Michael J. Sullivan 4072ad82fb Fix python 2 subprocess.Popen to produce Popen[bytes] (#3133)
Otherwise this causes a lot of spurious errors.
2019-07-19 14:17:32 -07:00
Michael J. Sullivan 90c2c22961 Make python 2 subprocess consistent with python 3 (#3132) 2019-07-19 10:56:59 -07:00
Sebastian Rittau dad16f2d43 Update socket exceptions (#3127)
* error is an alias for OSError in Python 3
* herror and gaierror can be constructed without arguments (tested
  in Python 2.7 and 3.7)
* timeout uses the same arguments as herror and gaierror
2019-07-18 16:50:28 -07:00
Yannack 40215d1fa3 Fix the definition of nsmallest() in stdlib/2 and 2and3/heapq.pyi (#3114)
Missing support of the optional "key" kwarg in nsmallest.
Also fixed nlargest syntax for 2and3 which was also missing.
Use a protocol for heapq.py
2019-07-18 21:38:28 +02:00
Sebastian Rittau 09d1055cd3 Remove mypy new analyzer tests (#3128)
Now that the new analyzer is the default, this does exactly the same
as the normal mypy self test.
2019-07-18 17:02:12 +02:00
Ivan Levkivskyi 508f992730 Add __eq__ to protobuf containers (#3126)
See https://github.com/protocolbuffers/protobuf/blob/master/python/google/protobuf/internal/containers.py.

Without these `mypy --strict-equality` causes false positives with protobufs.
2019-07-17 23:25:22 +01:00
William Ayd 8e89faa90f Added Optional (#3125)
Fixes #3124
2019-07-17 10:08:46 +02:00
Michael J. Sullivan 3ad3ed82c7 Overload the constructor of subprocess.Popen (#3113)
This takes advantage of a recent mypy change to respect the return
type of `__new__`. Using that it does the same tedious overloads
as `run` and `check_output`.
2019-07-16 15:41:33 -07:00
秋葉 e2ec5d0525 Make SyntaxError.text be optional (#3119)
Closes #3118
2019-07-15 09:11:45 +02:00
Anthony Sottile f76b7b273b Re-export _curses._CursesWindow from curses (#3117) 2019-07-13 08:01:10 -07:00
Anthony Sottile 2a57ce2cec Add curses.COLORS and curses.COLOR_PAIRS (#3115) 2019-07-13 07:50:13 -07:00
Rebecca Chen 40124b5f4c Update required pytype version to one that supports async def. (#3112) 2019-07-11 12:47:46 -07:00
Brandt Bucher 34b47101dd Slice attributes can be of any type. (#3024) 2019-07-11 12:13:32 -07:00
Ran Benita 4ae4714e00 sys: refine the return type of sys.exc_info() (#3111) 2019-07-11 10:43:37 +02:00
Michael J. Sullivan b43e1d674f Use Literal overloads to give better types to subprocess (#3110)
This gives better types to `subprocess.check_output` and `subprocess.run`
by laboriously overloading using literals.

To support `run`, I turned `CompletedProcess` into `_CompletedProcess[T]`
with `CompletedProcess = _CompletedProcess[Any]`. I could pretty easily
be convinced that it would be better to just make `CompletedProcess`
generic, though.

I'd like to do the same for Popen but need to make mypy support
believing the type of `__new__` in order for that to work.
2019-07-10 14:44:27 -07:00
Cole Maclean f5c107cacd BytesGenerator requires BinaryIO (#3106) 2019-07-07 22:03:07 -07:00
Sebastian Rittau 1436cfdef9 Add types to FileStorage (#3067) 2019-07-04 12:58:51 -07:00
Savo Kovačević 84e6492d7e Improving Flask stubs (#3003)
* Fix flask render_template and render_template_string stubs

* Add types for flask view function

* Import TracebackType from the right location

* Switch to bound typevar in route decorator stub

* Change render_template and render_template_string parameters to Text
2019-07-04 12:57:06 -07:00
Sam Zhou 4af283e1ac Fix HTTPConnection.putrequest parameter names (#3101) 2019-07-03 08:52:59 +02:00
ikelos 3e700224ba Add in multiprocessing.managers.ValueProxy types (#3100)
Fixes #1778
2019-07-03 08:49:16 +02:00
Francis Colas 75d9228b02 PurePath methods accept os.PathLike[str] from 3.6 (#3099)
Closes #3095
2019-07-02 13:08:32 +02:00
Rafi Blecher 668d050476 Fix contextlib GeneratorContextManager name for py>=3.2 (#3083) 2019-07-02 10:56:40 +01:00
Martijn Pieters e1e5c83795 QueueHandler / QueueListener accept SimpleQueue too (#3098)
The implementation of `logging.adapters.QueueHandler` and `logging.adapters.QueueListener` works great with `queue.SimpleQueue` too, so update the stub to reflect this.

The new queue.SimpleQueue class (introduced in 3.7) is faster but is not a Queue subclass as it doesn't implement task handling (`handle_task()` / `join()`) or queue bounds (raising `queue.Full` / `full()`). The logging handler / listener implementations do not make use of those features however.

Related Python bug, asking for an explicit documentation mention: https://bugs.python.org/issue37469
2019-07-01 07:47:30 -07:00
Ran Benita c66699800e xml.etree.ElementTree: fix missing None in get(), findtext() return type (#3093) 2019-07-01 14:28:40 +02:00
Jason Gilholme 8b66e08745 Add Generic Typing to Queue.PriorityQueue and Queue.LifoQueue in python 2 (#3036) 2019-07-01 14:05:13 +02:00
Hynek Schlawack 47450629c9 Add TLSVersion & related attributes to SSLContext (#3097) 2019-07-01 14:03:57 +02:00
Benjamin Woodruff 3272307933 Make dataclasses.Field.metadata non-optional (#3094)
If `metadata` is `None` the Field constructor replaces it with an empty
mapping object, so this value can never be None.

https://github.com/python/cpython/blob/v3.7.3/Lib/dataclasses.py#L243
2019-06-28 18:28:50 -07:00
Rebecca Chen 5dc89fe8cf Add undocumented methods codecs.utf_16_be_{decode,encode}. (#3091)
I found the signatures here:
https://github.com/python/cpython/blob/6a16b18224fa98f6d192aa5014affeccc0376eb3/Modules/_codecsmodule.c#L729

https://github.com/google/pytype/issues/348 was opened against
pytype about utf_16_be_encode being missing.
2019-06-26 20:29:16 -07:00
Gordon Ball 7e9e91cb7b Restore default value to click.echo_via_pager (#3090) 2019-06-26 13:21:05 -07:00
Eric Arellano 8131bfc3f6 Install Black and isort autoformatters (#3069)
* Install Black and isort

* Add config via pyproject.toml

Notably we keep the convention of 130 line length.

* Add target python version
2019-06-24 08:44:20 +02:00
redshiftzero 64b12bf7f1 itsdangerous: update JSONWebSignatureSerializer.dumps return type (#3082)
On Python 2, a str is returned, however on Python 3 the return type
is bytes.
2019-06-22 14:15:37 -07:00
Chad Dombrova e25c0cb128 "key" argument of builtin function sorted should be optional in python 2.7 (#3086) 2019-06-22 14:09:51 -07:00
Maarten ter Huurne bdd49d0f3a Fix annotation of re.Match 'lastindex' and 'lastgroup' in Python 3 (#3085)
Both are None if there were no groups matched. Also 'lastgroup'
will be None if the matched group was nameless.

The Python 2 versions of these annotations already used Optional.
2019-06-22 10:18:16 -07:00
Jelle Zijlstra b0c9fa4530 fix type of loop.sock_connect (#3073) 2019-06-21 17:31:51 +02:00
Jelle Zijlstra ada0570efc Revert "Define functools.partial as overloaded function instead of its own class (#2878)" (#3077)
This reverts commit e45f443d85.
2019-06-20 20:39:49 -07:00
crusaderky 9941616b9e Add mp_context parameter to concurrent.futures.ProcessPoolExecutor (#3078)
Closes #3076
2019-06-20 19:42:26 +02:00
秋葉 2b6a99c39c fix ssl.Purpose type in py3 (#3054) 2019-06-20 19:41:32 +02:00
Rune Tynan 58221cf20e Add types and functions in types.py that are new in 3.7 (#3066)
* Add types and functions in types.py that are new in 3.7

* Update `resolve_bases` to accept any iterable of objects, and the same
for `new_class` if the version is at least 3.7

* Add comparison overrides implemented by MethodWrapperType

* Fix mypy error due to over-constrained `__eq__`
2019-06-19 15:20:57 -07:00
Eric Arellano 1763f51c0d Refactor tests/pytype_test.py (#3065) 2019-06-19 15:19:10 -07:00
Florian Ludwig 2e10326b50 change http.cookies.Morsel to Dict[str, Any] (#3060)
Morsel does cast any value to string and therfor any is the correct
typehint. For some keys other types then strings are more
appropiate anyway, max-age can take an integer (unix time) and http-only
a boolean.

Closes #3059
2019-06-19 15:17:16 -07:00
Matthew Wilkes d149fe435c Represent the use of IntEnums in functions in socket.py. (#3009)
The Pull Request #1121 added the `AddressFamily` type to `socket.pyi`
for Python 3.4+, so constants such as `AF_INET` are correctly
represented as being an enum member rather than an int. The same is
true of the `SocketKind` enums in the `SOCK_*` family.

Various functions in the socket module can accept either an int
or an `AF_*` enum member as arguments, which is allowed by the
int argument type. However the `getaddrinfo` function returns an
`AddressFamily` member rather than an int in the first position
of its list members, so code that access enum specific members
such as the `name` attribute causes a typing error to be found.

This change corrects the return type of `getaddrinfo` but leaves
the family parameters as int, given that `AddressFamily` members
are `IntEnum` and only ever treated as `int`s internally.
2019-06-19 15:14:15 -07:00
Motoki Naruse aa56af7dce HTMLParser.get_starttag_text() can return None (#3072) 2019-06-19 15:34:37 +02:00
Mathieu Bridon 38f253ed69 redis: Add some type hints (#3055) 2019-06-18 18:19:51 +02:00
Ivan Levkivskyi 01c2fa5a14 Sync recent typing and typing_extensions updates (#3070)
This includes two things to sync up with recent runtime updates:
* Move `Final`, `@final`, `Literal`, and `TypedDict` to `typing` (`typing_extensions` still defines or re-exports them)
* Rename `@typing.runtime` to `@typing.runtime_checkable`, while keeping `@runtime` as a backwards-compatible alias in `typing_extensions`.
2019-06-18 02:31:54 +01:00
Carl Meyer fcb97fe8f1 Overload ast.parse to recognize that mode=exec means Module return. (#3039) 2019-06-17 23:27:14 +02:00
Jadiker 5447ff6bfe str and unicode format functions take objects (#3068) 2019-06-17 20:09:11 +02:00
Alexander Fasching 6258e7ddfd ssl.pyi: fix types of cadata argument (#3063) 2019-06-16 14:11:10 -07:00
Sean Vig 1efebf78e4 Marshal dumps/loads uses bytes (#3061)
The marshal.dumps and marshal.loads functions should return and accept
bytes, respectively, rather than a string.
2019-06-16 16:17:26 +02:00
Eric Arellano d36a519b95 Update select and selectors to use _HasFileno protocol (#3057) 2019-06-15 16:35:18 -07:00
Mark Mendoza 1f740a7926 Adding stubs for pyre_extensions (#3056) 2019-06-13 23:14:54 +02:00
Joe Juzl 8ffe20fc22 Add redis stream methods to the client stubs (#3051) 2019-06-13 09:24:39 -07:00
Utkarsh Gupta 8e7c32846f request.pyi: Change Union[] -> Any for attributing status. (#3045)
Fixes #3026
2019-06-13 12:01:13 +02:00
John Freeman e4a9cd580c Add missing path-like annotation (#3053)
Fixes #3052
2019-06-12 20:03:14 +02:00
Sebastian Rittau b9101e9c5e Add a few Redis types (#3016)
* StrictRedis is an alias for Redis in current redis

* Add a few types

* Add missing import

* Add missing argument and types
2019-06-12 09:18:48 -07:00
Ivan Levkivskyi 5327484176 Use type annotation syntax (#3048) 2019-06-10 20:20:59 -07:00
Walter Scott Johnson 901cb33a3c Mark asyncio loop parameters as Optional (#3047) 2019-06-10 20:58:31 +02:00
Anthony Sottile ed2a851ed8 dateutil: byweekday can take weekday (#3046) 2019-06-10 11:21:50 -07:00
Connor Skees 55a566340a Add copy() method to requests.Session.headers (#3043)
* Add `copy()` method to requests.Session.headers

* Use one type annotation
2019-06-08 12:19:57 -07:00
Rebecca Chen d64a26cf99 Add missing constructor to types.CodeType. (#3040)
I got the argument order from
https://github.com/python/cpython/blob/2bfc2dc214445550521074f428245b502d215eac/Objects/codeobject.c#L263
and the types from the attributes already in the stub.
2019-06-08 07:07:29 -07:00
Rebecca Chen e7184d6dfc Add undocumented but used method LWPCookieJar.as_lwp_str. (#3041)
The method is defined here:
https://github.com/python/cpython/blob/e36ed475ea429f7cc80a4d65f80b44686a74b246/Lib/http/cookiejar.py#L1864
2019-06-08 07:06:14 -07:00
Ivan Levkivskyi 61eb99664b Add new semantic analyzer to mypy tests (#3037)
This also removes two redundant definitions in curses/__init__.pyi star-imported from _curses.
2019-06-07 16:49:57 +01:00
nabnut 87f96dc1f0 Add stub for queue.SimpleQueue in 3.7 (#2995)
Closes: #2994
2019-06-07 11:50:39 +02:00
markedwards 5c94b58752 Add FullLoader and FullConstructor classes to yaml (#3035) 2019-06-06 17:47:39 +02:00
Evan Moses db5fc492aa Added tojson_filter and detect_encoding to flask.json (#3030) 2019-06-05 23:39:49 +02:00
J Rob Gant 40c4e4ff3d Annotate HTMLParser attribute optional value (#3034)
Closes #3031
2019-06-05 18:51:52 +02:00
Sebastian Rittau 0e5b3770f8 Add a "pull requests welcome" batch (#3033)
We get quite a few bug reports where after a maintainer writes
"Pull Requests Welcome" we get a PR by the submitter. Maybe this
badge will help a bit to encourage people directly submit PRs,
reducing maintainer workload.
2019-06-05 07:51:01 -07:00
Benjamin Peterson d6e2b02f72 Use custom tuple subclass for pwd.struct_passwd (#3017) 2019-06-05 11:59:32 +02:00
Radu Matei Lăcraru a7785151aa Make AsyncGeneratorType.aclose() properly return Awaitable[None] (#3032) 2019-06-05 11:20:23 +02:00
Chandan Singh 233f2abf19 click: Use property decorator for read-only properties (#3028)
Since these properties do not have a setter, be explicit with the
`@property` decorator. This will allow type checkers to see that
assignment of these attributes is an error.

See https://github.com/python/typeshed/pull/3027#discussion_r289623016
for some related context.
2019-06-03 08:13:52 -07:00
Chandan Singh 018ecb3f16 Update Click to 7.0 (#3027)
Closes #3020.
2019-06-03 07:38:27 -07:00
Rebecca Chen f8093d63cd Move stdlib/3/curses to stdlib/2and3/curses. (#3025)
Also add the A_ITALIC constant, which is new in 3.7.
2019-06-01 10:51:07 +02:00
秋葉 dd244d1200 fix Sniffer.sniff return type (#3023) 2019-05-31 07:22:36 -07:00
Mathieu Bridon 6061ca404e Move Redis stubs to 2and3 (#3015)
They actually work for both Python 2 and 3, mostly because they aren't
really typed yet.
2019-05-29 15:45:46 +02:00
Mark Mendoza d8e14d6ead [pyre] Adding IntVar to typing_extensions (#3008) 2019-05-28 19:48:13 +02:00
Utkarsh Gupta 020449a1ed argparse.pyi: Allow Callable[[Text], _T] (#3013)
Fixes #2988
2019-05-27 14:39:04 +02:00
Brian Brunner 53500c8750 Make Timer args less restrictive (#3007)
Closes #3004
2019-05-23 15:08:48 +02:00
Sebastian Rittau 260369e6e7 Use typing.Text for argument types (#3000)
Also, use just str for argument types in Python 3+ branches.
2019-05-21 19:53:47 -07:00
Ran Benita 45266c9c32 Allow is_dst=None in pytz.BaseTzInfo.localize() (#3002)
See http://pytz.sourceforge.net/#problems-with-localtime
2019-05-21 10:16:30 +02:00
Viktor Roytman 07d4938251 Add missing methods to ItemsView and KeysView, including isdisjoint (#2997) 2019-05-20 02:12:22 +02:00
501 changed files with 12468 additions and 10400 deletions
+1 -3
View File
@@ -5,7 +5,7 @@
# 7155 E302 expected 2 blank lines
# 1463 F401 imported but unused
# 967 E701 multiple statements on one line (colon)
# 457 F811 redefinition
# 457 F811 redefinition (should be fixed in pyflakes 2.1.2)
# 390 E305 expected 2 blank lines
# 4 E741 ambiguous variable name
@@ -18,8 +18,6 @@
[flake8]
ignore = F401, F403, F405, F811, E301, E302, E305, E501, E701, E704, E741, B303, W504
# We are checking with Python 3 but many of the stubs are Python 2 stubs.
# A nice future improvement would be to provide separate .flake8
# configurations for Python 2 and Python 3 files.
builtins = StandardError,apply,basestring,buffer,cmp,coerce,execfile,file,intern,long,raw_input,reduce,reload,unichr,unicode,xrange
exclude = .venv*,@*,.git
max-line-length = 130
+23 -22
View File
@@ -1,30 +1,31 @@
dist: xenial
dist: bionic
language: python
python: 3.7
python: 3.8
matrix:
jobs:
include:
- name: "pytype"
python: 3.6
env:
- TEST_CMD="./tests/pytype_test.py"
- INSTALL="test"
- name: "mypy"
env:
- TEST_CMD="./tests/mypy_test.py"
- INSTALL="mypy"
install: pip install -r requirements-tests-py3.txt
script: ./tests/pytype_test.py
- name: "mypy (typed-ast)"
python: 3.7
install: pip install -U git+git://github.com/python/mypy git+git://github.com/python/typed_ast
script: ./tests/mypy_test.py --platform=linux
- name: "mypy (ast)"
python: 3.8
install: pip install -U git+git://github.com/python/mypy
script: ./tests/mypy_test.py --platform=linux
- name: "mypy (Windows)"
install: pip install -U git+git://github.com/python/mypy
script: ./tests/mypy_test.py --platform=win32
- name: "mypy (Darwin)"
install: pip install -U git+git://github.com/python/mypy
script: ./tests/mypy_test.py --platform=darwin
- name: "mypy self test"
env: TEST_CMD="./tests/mypy_selftest.py"
script: ./tests/mypy_selftest.py
- name: "check file consistency"
env: TEST_CMD="./tests/check_consistent.py"
script: ./tests/check_consistent.py
- name: "flake8"
env:
- TEST_CMD="flake8"
- INSTALL="test"
install:
- if [[ $INSTALL == 'test' ]]; then pip install -r requirements-tests-py3.txt; fi
- if [[ $INSTALL == 'mypy' ]]; then pip install -U git+git://github.com/python/mypy git+git://github.com/python/typed_ast; fi
script:
- $TEST_CMD
install: pip install -r requirements-tests-py3.txt
script: flake8
+23 -30
View File
@@ -11,13 +11,11 @@ are important to the project's success.
1. Read the [README.md file](README.md).
2. Set up your environment to be able to [run all tests](README.md#running-the-tests). They should pass.
3. [Prepare your changes](#preparing-changes):
* [Contact us](#discussion) before starting significant work.
* IMPORTANT: For new libraries, [get permission from the library owner first](#adding-a-new-library).
* Small fixes and additions can be submitted directly as pull requests,
but [contact us](#discussion) before starting significant work.
* Create your stubs [conforming to the coding style](#stub-file-coding-style).
* Make sure your tests pass cleanly on `mypy`, `pytype`, and `flake8`.
4. [Submit your changes](#submitting-changes):
* Open a pull request
* For new libraries, [include a reference to where you got permission](#adding-a-new-library)
4. [Submit your changes](#submitting-changes) by opening a pull request.
5. You can expect a reply within a few days:
* Diffs are merged when considered ready by the core team.
* Feel free to ping the core team if your pull request goes without
@@ -103,21 +101,6 @@ recommend starting by opening an issue laying out what you want to do.
That lets a conversation happen early in case other contributors disagree
with what you'd like to do or have ideas that will help you do it.
### Adding a new library
If you want to submit type stubs for a new library, you need to
**contact the maintainers of the original library** first to let them
know and **get their permission**. Do it by opening an issue on their
project's bug tracker. This gives them the opportunity to
consider adopting type hints directly in their codebase (which you
should prefer to external type stubs). When the project owners agree
for you to submit stubs here or you do not receive a reply within
one month, open a pull request **referencing the
issue where you asked for permission**.
Make sure your changes pass the tests (the [README](README.md#running-the-tests)
has more information).
### What to include
Stubs should include the complete interface (classes, functions,
@@ -237,7 +220,7 @@ rule is that they should be as concise as possible. Specifically:
* use variable annotations instead of type comments, even for stubs
that target older versions of Python;
* for arguments with a type and a default, use spaces around the `=`.
The code formatter [black](https://github.com/python/black) will format
The code formatter [black](https://github.com/psf/black) will format
stubs according to this standard.
Stub files should only contain information necessary for the type
@@ -291,6 +274,15 @@ Type variables and aliases you introduce purely for legibility reasons
should be prefixed with an underscore to make it obvious to the reader
they are not part of the stubbed API.
When adding type annotations for context manager classes, annotate
the return type of `__exit__` as bool only if the context manager
sometimes suppresses annotations -- if it sometimes returns `True`
at runtime. If the context manager never suppresses exceptions,
have the return type be either `None` or `Optional[bool]`. If you
are not sure whether exceptions are suppressed or not or if the
context manager is meant to be subclassed, pick `Optional[bool]`.
See https://github.com/python/mypy/issues/7214 for more details.
NOTE: there are stubs in this repository that don't conform to the
style described above. Fixing them is a great starting point for new
contributors.
@@ -306,8 +298,8 @@ and optionally the lowest minor version, with the exception of the `2and3`
directory which applies to both Python 2 and 3.
For example, stubs in the `3` directory will be applied to all versions of
Python 3, though stubs in the `3.6` directory will only be applied to versions
3.6 and above. However, stubs in the `2` directory will not be applied to
Python 3, though stubs in the `3.7` directory will only be applied to versions
3.7 and above. However, stubs in the `2` directory will not be applied to
Python 3.
It is preferred to use a single stub in the more generic directory that
@@ -317,7 +309,7 @@ if the given library works on both Python 2 and Python 3, prefer to put your
stubs in the `2and3` directory, unless the types are so different that the stubs
become unreadable that way.
You can use checks like `if sys.version_info >= (3, 4):` to denote new
You can use checks like `if sys.version_info >= (3, 8):` to denote new
functionality introduced in a given Python version or solve type
differences. When doing so, only use one-tuples or two-tuples. This is
because:
@@ -330,17 +322,17 @@ because:
regardless of the micro version used.
Because of this, if a given functionality was introduced in, say, Python
3.4.4, your check:
3.7.4, your check:
* should be expressed as `if sys.version_info >= (3, 4):`
* should NOT be expressed as `if sys.version_info >= (3, 4, 4):`
* should NOT be expressed as `if sys.version_info >= (3, 5):`
* should be expressed as `if sys.version_info >= (3, 7):`
* should NOT be expressed as `if sys.version_info >= (3, 7, 4):`
* should NOT be expressed as `if sys.version_info >= (3, 8):`
This makes the type checker assume the functionality was also available
in 3.4.0 - 3.4.3, which while *technically* incorrect is relatively
in 3.7.0 - 3.7.3, which while *technically* incorrect is relatively
harmless. This is a strictly better compromise than using the latter
two forms, which would generate false positive errors for correct use
under Python 3.4.4.
under Python 3.7.4.
Note: in its current implementation, typeshed cannot contain stubs for
multiple versions of the same third-party library. Prefer to generate
@@ -380,3 +372,4 @@ Core developers should follow these rules when processing pull requests:
* Delete branches for merged PRs (by core devs pushing to the main repo).
* Make sure commit messages to master are meaningful. For example, remove irrelevant
intermediate commit messages.
* If stubs for a new library are submitted, notify the library's maintainers.
+12 -6
View File
@@ -2,19 +2,22 @@
[![Build Status](https://travis-ci.org/python/typeshed.svg?branch=master)](https://travis-ci.org/python/typeshed)
[![Chat at https://gitter.im/python/typing](https://badges.gitter.im/python/typing.svg)](https://gitter.im/python/typing?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Pull Requests Welcome](https://img.shields.io/badge/pull%20requests-welcome-brightgreen.svg)](https://github.com/python/typeshed/blob/master/CONTRIBUTING.md)
## About
Typeshed contains external type annotations for the Python standard library
and Python builtins, as well as third party packages.
and Python builtins, as well as third party packages as contributed by
people external to those projects.
This data can e.g. be used for static analysis, type checking or type inference.
For information on how to use `typeshed`, read below. Information for
contributors can be found in [CONTRIBUTING.md](CONTRIBUTING.md). **Please read
it before submitting pull requests.**
it before submitting pull requests; do not report issues with annotations to
the project the stubs are for, but instead report them here to typeshed.**
Typeshed supports Python versions 2.7 and 3.4 and up.
Typeshed supports Python versions 2.7 and 3.5 and up.
## Using
@@ -44,10 +47,13 @@ pytype repo.
## Format
Each Python module is represented by a `.pyi` "stub". This is a normal Python
file (i.e., it can be interpreted by Python 3), except all the methods are empty.
Each Python module is represented by a `.pyi` "stub file". This is a
syntactically valid Python file, although it usually cannot be run by
Python 3 (since forward references don't require string quotes). All
the methods are empty.
Python function annotations ([PEP 3107](https://www.python.org/dev/peps/pep-3107/))
are used to describe the types the function has.
are used to describe the signature of each function or method.
See [PEP 484](http://www.python.org/dev/peps/pep-0484/) for the exact
syntax of the stub files and [CONTRIBUTING.md](CONTRIBUTING.md) for the
+11
View File
@@ -0,0 +1,11 @@
[tool.black]
line_length = 130
target_version = ["py37"]
[tool.isort]
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
combine_as_imports = true
line_length = 130
+6 -4
View File
@@ -1,6 +1,8 @@
git+https://github.com/python/mypy.git@master
typed-ast>=1.0.4
flake8==3.6.0
flake8-bugbear==18.8.0
flake8-pyi==18.3.1
pytype>=2019.5.15
black==19.3b0
flake8==3.7.8
flake8-bugbear==19.8.0
flake8-pyi==19.3.0
isort==4.3.21
pytype>=2019.10.17
+3 -3
View File
@@ -1,6 +1,6 @@
# Stubs for BaseHTTPServer (Python 2.7)
from typing import Any, BinaryIO, Mapping, Optional, Tuple, Union
from typing import Any, BinaryIO, Callable, Mapping, Optional, Tuple, Union
import SocketServer
import mimetools
@@ -8,9 +8,9 @@ class HTTPServer(SocketServer.TCPServer):
server_name: str
server_port: int
def __init__(self, server_address: Tuple[str, int],
RequestHandlerClass: type) -> None: ...
RequestHandlerClass: Callable[..., BaseHTTPRequestHandler]) -> None: ...
class BaseHTTPRequestHandler:
class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler):
client_address: Tuple[str, int]
server: SocketServer.BaseServer
close_connection: bool
+8
View File
@@ -0,0 +1,8 @@
# Stubs for CGIHTTPServer (Python 2.7)
from typing import List
import SimpleHTTPServer
class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
cgi_directories: List[str]
def do_POST(self) -> None: ...
+7 -5
View File
@@ -55,8 +55,8 @@ class _Readable(Protocol):
class RawConfigParser:
_dict: Any
_sections: dict
_defaults: dict
_sections: Dict[Any, Any]
_defaults: Dict[Any, Any]
_optcre: Any
SECTCRE: Any
OPTCRE: Any
@@ -86,12 +86,14 @@ class RawConfigParser:
class ConfigParser(RawConfigParser):
_KEYCRE: Any
def get(self, section: str, option: str, raw: bool = ..., vars: Optional[dict] = ...) -> Any: ...
def items(self, section: str, raw: bool = ..., vars: Optional[dict] = ...) -> List[Tuple[str, Any]]: ...
def get(self, section: str, option: str, raw: bool = ..., vars: Optional[Dict[Any, Any]] = ...) -> Any: ...
def items(self, section: str, raw: bool = ..., vars: Optional[Dict[Any, Any]] = ...) -> List[Tuple[str, Any]]: ...
def _interpolate(self, section: str, option: str, rawval: Any, vars: Any) -> str: ...
def _interpolation_replace(self, match: Any) -> str: ...
class SafeConfigParser(ConfigParser):
_interpvar_re: Any
def _interpolate(self, section: str, option: str, rawval: Any, vars: Any) -> str: ...
def _interpolate_some(self, option: str, accum: list, rest: str, section: str, map: dict, depth: int) -> None: ...
def _interpolate_some(
self, option: str, accum: List[Any], rest: str, section: str, map: Dict[Any, Any], depth: int,
) -> None: ...
+3 -3
View File
@@ -1,8 +1,8 @@
from typing import Any, Optional
from typing import Any, Dict, Optional
class CookieError(Exception): ...
class Morsel(dict):
class Morsel(Dict[Any, Any]):
key: Any
def __init__(self): ...
def __setitem__(self, K, V): ...
@@ -14,7 +14,7 @@ class Morsel(dict):
def js_output(self, attrs: Optional[Any] = ...): ...
def OutputString(self, attrs: Optional[Any] = ...): ...
class BaseCookie(dict):
class BaseCookie(Dict[Any, Any]):
def value_decode(self, val): ...
def value_encode(self, val): ...
def __init__(self, input: Optional[Any] = ...): ...
+4 -4
View File
@@ -1,7 +1,7 @@
# Stubs for Queue (Python 2)
from collections import deque
from typing import Any, TypeVar, Generic, Optional
from typing import Any, Deque, TypeVar, Generic, Optional
_T = TypeVar('_T')
@@ -15,7 +15,7 @@ class Queue(Generic[_T]):
not_full: Any
all_tasks_done: Any
unfinished_tasks: Any
queue: deque # undocumented
queue: Deque[Any] # undocumented
def __init__(self, maxsize: int = ...) -> None: ...
def task_done(self) -> None: ...
def join(self) -> None: ...
@@ -27,5 +27,5 @@ class Queue(Generic[_T]):
def get(self, block: bool = ..., timeout: Optional[float] = ...) -> _T: ...
def get_nowait(self) -> _T: ...
class PriorityQueue(Queue): ...
class LifoQueue(Queue): ...
class PriorityQueue(Queue[_T]): ...
class LifoQueue(Queue[_T]): ...
+1 -1
View File
@@ -9,7 +9,7 @@ class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_GET(self) -> None: ...
def do_HEAD(self) -> None: ...
def send_head(self) -> Optional[IO[str]]: ...
def list_directory(self, path: Union[str, unicode]) -> Optional[StringIO]: ...
def list_directory(self, path: Union[str, unicode]) -> Optional[StringIO[Any]]: ...
def translate_path(self, path: AnyStr) -> AnyStr: ...
def copyfile(self, source: IO[AnyStr], outputfile: IO[AnyStr]): ...
def guess_type(self, path: Union[str, unicode]) -> str: ...
+11 -11
View File
@@ -1,22 +1,22 @@
# NB: SocketServer.pyi and socketserver.pyi must remain consistent!
# Stubs for socketserver
from typing import Any, BinaryIO, Optional, Tuple, Type
from typing import Any, BinaryIO, Callable, Optional, Tuple, Type, Text, Union
from socket import SocketType
import sys
import types
class BaseServer:
address_family: int
RequestHandlerClass: type
RequestHandlerClass: Callable[..., BaseRequestHandler]
server_address: Tuple[str, int]
socket: SocketType
allow_reuse_address: bool
request_queue_size: int
socket_type: int
timeout: Optional[float]
def __init__(self, server_address: Tuple[str, int],
RequestHandlerClass: type) -> None: ...
def __init__(self, server_address: Any,
RequestHandlerClass: Callable[..., BaseRequestHandler]) -> None: ...
def fileno(self) -> int: ...
def handle_request(self) -> None: ...
def serve_forever(self, poll_interval: float = ...) -> None: ...
@@ -38,29 +38,29 @@ class BaseServer:
def __enter__(self) -> BaseServer: ...
def __exit__(self, exc_type: Optional[Type[BaseException]],
exc_val: Optional[BaseException],
exc_tb: Optional[types.TracebackType]) -> bool: ...
exc_tb: Optional[types.TracebackType]) -> None: ...
if sys.version_info >= (3, 3):
def service_actions(self) -> None: ...
class TCPServer(BaseServer):
def __init__(self, server_address: Tuple[str, int],
RequestHandlerClass: type,
RequestHandlerClass: Callable[..., BaseRequestHandler],
bind_and_activate: bool = ...) -> None: ...
class UDPServer(BaseServer):
def __init__(self, server_address: Tuple[str, int],
RequestHandlerClass: type,
RequestHandlerClass: Callable[..., BaseRequestHandler],
bind_and_activate: bool = ...) -> None: ...
if sys.platform != 'win32':
class UnixStreamServer(BaseServer):
def __init__(self, server_address: Tuple[str, int],
RequestHandlerClass: type,
def __init__(self, server_address: Union[Text, bytes],
RequestHandlerClass: Callable[..., BaseRequestHandler],
bind_and_activate: bool = ...) -> None: ...
class UnixDatagramServer(BaseServer):
def __init__(self, server_address: Tuple[str, int],
RequestHandlerClass: type,
def __init__(self, server_address: Union[Text, bytes],
RequestHandlerClass: Callable[..., BaseRequestHandler],
bind_and_activate: bool = ...) -> None: ...
class ForkingMixIn: ...
+1 -1
View File
@@ -6,7 +6,7 @@ _VT = TypeVar('_VT')
_T = TypeVar('_T')
class UserDict(Dict[_KT, _VT], Generic[_KT, _VT]):
data: Mapping[_KT, _VT]
data: Dict[_KT, _VT]
def __init__(self, initialdata: Mapping[_KT, _VT] = ...) -> None: ...
+4 -3
View File
@@ -1,9 +1,10 @@
from typing import Iterable, MutableSequence, TypeVar, Union, overload
from typing import Iterable, MutableSequence, TypeVar, Union, overload, List
_T = TypeVar("_T")
_ULT = TypeVar("_ULT", bound=UserList)
_S = TypeVar("_S")
class UserList(MutableSequence[_T]):
data: List[_T]
def insert(self, index: int, object: _T) -> None: ...
@overload
def __setitem__(self, i: int, o: _T) -> None: ...
@@ -14,5 +15,5 @@ class UserList(MutableSequence[_T]):
@overload
def __getitem__(self, i: int) -> _T: ...
@overload
def __getitem__(self: _ULT, s: slice) -> _ULT: ...
def __getitem__(self: _S, s: slice) -> _S: ...
def sort(self) -> None: ...
+1 -1
View File
@@ -62,7 +62,7 @@ class UserString(Sequence[UserString]):
def upper(self: _UST) -> _UST: ...
def zfill(self: _UST, width: int) -> _UST: ...
class MutableString(UserString, MutableSequence[MutableString]): # type: ignore
class MutableString(UserString, MutableSequence[MutableString]):
@overload
def __getitem__(self: _MST, i: int) -> _MST: ...
@overload
+87 -59
View File
@@ -17,6 +17,11 @@ import sys
if sys.version_info >= (3,):
from typing import SupportsBytes, SupportsRound
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
_T = TypeVar('_T')
_T_co = TypeVar('_T_co', covariant=True)
_KT = TypeVar('_KT')
@@ -29,6 +34,9 @@ _T4 = TypeVar('_T4')
_T5 = TypeVar('_T5')
_TT = TypeVar('_TT', bound='type')
class _SupportsIndex(Protocol):
def __index__(self) -> int: ...
class object:
__doc__: Optional[str]
__dict__: Dict[str, Any]
@@ -53,30 +61,30 @@ class object:
def __getattribute__(self, name: str) -> Any: ...
def __delattr__(self, name: str) -> None: ...
def __sizeof__(self) -> int: ...
def __reduce__(self) -> tuple: ...
def __reduce_ex__(self, protocol: int) -> tuple: ...
def __reduce__(self) -> Union[str, Tuple[Any, ...]]: ...
def __reduce_ex__(self, protocol: int) -> Union[str, Tuple[Any, ...]]: ...
if sys.version_info >= (3,):
def __dir__(self) -> Iterable[str]: ...
if sys.version_info >= (3, 6):
def __init_subclass__(cls) -> None: ...
class staticmethod(object): # Special, only valid as a decorator.
__func__: Callable
__func__: Callable[..., Any]
if sys.version_info >= (3,):
__isabstractmethod__: bool
def __init__(self, f: Callable) -> None: ...
def __init__(self, f: Callable[..., Any]) -> None: ...
def __new__(cls: Type[_T], *args: Any, **kwargs: Any) -> _T: ...
def __get__(self, obj: _T, type: Optional[Type[_T]] = ...) -> Callable: ...
def __get__(self, obj: _T, type: Optional[Type[_T]] = ...) -> Callable[..., Any]: ...
class classmethod(object): # Special, only valid as a decorator.
__func__: Callable
__func__: Callable[..., Any]
if sys.version_info >= (3,):
__isabstractmethod__: bool
def __init__(self, f: Callable) -> None: ...
def __init__(self, f: Callable[..., Any]) -> None: ...
def __new__(cls: Type[_T], *args: Any, **kwargs: Any) -> _T: ...
def __get__(self, obj: _T, type: Optional[Type[_T]] = ...) -> Callable: ...
def __get__(self, obj: _T, type: Optional[Type[_T]] = ...) -> Callable[..., Any]: ...
class type(object):
__base__: type
@@ -129,10 +137,12 @@ class super(object):
class int:
@overload
def __init__(self, x: Union[Text, bytes, SupportsInt] = ...) -> None: ...
def __init__(self, x: Union[Text, bytes, SupportsInt, _SupportsIndex] = ...) -> None: ...
@overload
def __init__(self, x: Union[Text, bytes, bytearray], base: int) -> None: ...
if sys.version_info >= (3, 8):
def as_integer_ratio(self) -> Tuple[int, Literal[1]]: ...
@property
def real(self) -> int: ...
@property
@@ -168,7 +178,7 @@ class int:
def __rtruediv__(self, x: int) -> float: ...
def __rmod__(self, x: int) -> int: ...
def __rdivmod__(self, x: int) -> Tuple[int, int]: ...
def __pow__(self, x: int) -> Any: ... # Return type can be int or float, depending on x.
def __pow__(self, __x: int, __modulo: Optional[int] = ...) -> Any: ... # Return type can be int or float, depending on x.
def __rpow__(self, x: int) -> Any: ...
def __and__(self, n: int) -> int: ...
def __or__(self, n: int) -> int: ...
@@ -183,7 +193,10 @@ class int:
def __neg__(self) -> int: ...
def __pos__(self) -> int: ...
def __invert__(self) -> int: ...
def __trunc__(self) -> int: ...
if sys.version_info >= (3,):
def __ceil__(self) -> int: ...
def __floor__(self) -> int: ...
def __round__(self, ndigits: Optional[int] = ...) -> int: ...
def __getnewargs__(self) -> Tuple[int]: ...
@@ -206,7 +219,7 @@ class int:
def __index__(self) -> int: ...
class float:
def __init__(self, x: Union[SupportsFloat, Text, bytes, bytearray] = ...) -> None: ...
def __init__(self, x: Union[SupportsFloat, _SupportsIndex, Text, bytes, bytearray] = ...) -> None: ...
def as_integer_ratio(self) -> Tuple[int, int]: ...
def hex(self) -> str: ...
def is_integer(self) -> bool: ...
@@ -240,11 +253,10 @@ class float:
def __rdivmod__(self, x: float) -> Tuple[float, float]: ...
def __rpow__(self, x: float) -> float: ...
def __getnewargs__(self) -> Tuple[float]: ...
def __trunc__(self) -> int: ...
if sys.version_info >= (3,):
@overload
def __round__(self) -> int: ...
@overload
def __round__(self, ndigits: None) -> int: ...
def __round__(self, ndigits: None = ...) -> int: ...
@overload
def __round__(self, ndigits: int) -> float: ...
@@ -269,11 +281,9 @@ class float:
class complex:
@overload
def __init__(self, re: float = ..., im: float = ...) -> None: ...
def __init__(self, real: float = ..., imag: float = ...) -> None: ...
@overload
def __init__(self, s: str) -> None: ...
@overload
def __init__(self, s: SupportsComplex) -> None: ...
def __init__(self, real: Union[str, SupportsComplex, _SupportsIndex]) -> None: ...
@property
def real(self) -> float: ...
@@ -332,7 +342,7 @@ else:
end: int = ...) -> bool: ...
def expandtabs(self, tabsize: int = ...) -> unicode: ...
def find(self, sub: unicode, start: int = ..., end: int = ...) -> int: ...
def format(self, *args: Any, **kwargs: Any) -> unicode: ...
def format(self, *args: object, **kwargs: object) -> unicode: ...
def index(self, sub: unicode, start: int = ..., end: int = ...) -> int: ...
def isalnum(self) -> bool: ...
def isalpha(self) -> bool: ...
@@ -421,7 +431,7 @@ class str(Sequence[str], _str_base):
def endswith(self, suffix: Union[Text, Tuple[Text, ...]]) -> bool: ...
def expandtabs(self, tabsize: int = ...) -> str: ...
def find(self, sub: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ...
def format(self, *args: Any, **kwargs: Any) -> str: ...
def format(self, *args: object, **kwargs: object) -> str: ...
if sys.version_info >= (3,):
def format_map(self, map: Mapping[str, Any]) -> str: ...
def index(self, sub: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ...
@@ -667,6 +677,8 @@ class bytearray(MutableSequence[int], ByteString):
def decode(self, encoding: Text = ..., errors: Text = ...) -> str: ...
def endswith(self, suffix: Union[bytes, Tuple[bytes, ...]]) -> bool: ...
def expandtabs(self, tabsize: int = ...) -> bytearray: ...
if sys.version_info < (3,):
def extend(self, iterable: Union[str, Iterable[int]]) -> None: ...
if sys.version_info >= (3,):
def find(self, sub: Union[bytes, int], start: Optional[int] = ..., end: Optional[int] = ...) -> int: ...
if sys.version_info >= (3, 5):
@@ -734,7 +746,7 @@ class bytearray(MutableSequence[int], ByteString):
def __repr__(self) -> str: ...
def __int__(self) -> int: ...
def __float__(self) -> float: ...
def __hash__(self) -> int: ...
__hash__: None # type: ignore
@overload
def __getitem__(self, i: int) -> int: ...
@overload
@@ -784,9 +796,10 @@ class memoryview(Sized, Container[_mv_container_type]):
c_contiguous: bool
f_contiguous: bool
contiguous: bool
nbytes: int
def __init__(self, obj: Union[bytes, bytearray, memoryview]) -> None: ...
def __enter__(self) -> memoryview: ...
def __exit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]) -> bool: ...
def __exit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]) -> None: ...
else:
def __init__(self, obj: Union[bytes, bytearray, buffer, memoryview]) -> None: ...
@@ -799,16 +812,19 @@ class memoryview(Sized, Container[_mv_container_type]):
def __iter__(self) -> Iterator[_mv_container_type]: ...
def __len__(self) -> int: ...
@overload
def __setitem__(self, s: slice, o: memoryview) -> None: ...
@overload
def __setitem__(self, i: int, o: bytes) -> None: ...
@overload
def __setitem__(self, s: slice, o: Sequence[bytes]) -> None: ...
@overload
def __setitem__(self, s: slice, o: memoryview) -> None: ...
def tobytes(self) -> bytes: ...
def tolist(self) -> List[int]: ...
if sys.version_info >= (3, 2):
def release(self) -> None: ...
if sys.version_info >= (3, 5):
def hex(self) -> str: ...
@@ -841,13 +857,14 @@ class bool(int):
def __getnewargs__(self) -> Tuple[int]: ...
class slice(object):
start: Optional[int]
step: Optional[int]
stop: Optional[int]
start: Any
step: Any
stop: Any
@overload
def __init__(self, stop: Optional[int]) -> None: ...
def __init__(self, stop: Any) -> None: ...
@overload
def __init__(self, start: Optional[int], stop: Optional[int], step: Optional[int] = ...) -> None: ...
def __init__(self, start: Any, stop: Any, step: Any = ...) -> None: ...
__hash__: None # type: ignore
def indices(self, len: int) -> Tuple[int, int, int]: ...
class tuple(Sequence[_T_co], Generic[_T_co]):
@@ -863,7 +880,10 @@ class tuple(Sequence[_T_co], Generic[_T_co]):
def __le__(self, x: Tuple[_T_co, ...]) -> bool: ...
def __gt__(self, x: Tuple[_T_co, ...]) -> bool: ...
def __ge__(self, x: Tuple[_T_co, ...]) -> bool: ...
@overload
def __add__(self, x: Tuple[_T_co, ...]) -> Tuple[_T_co, ...]: ...
@overload
def __add__(self, x: Tuple[Any, ...]) -> Tuple[Any, ...]: ...
def __mul__(self, n: int) -> Tuple[_T_co, ...]: ...
def __rmul__(self, n: int) -> Tuple[_T_co, ...]: ...
def count(self, x: Any) -> int: ...
@@ -876,9 +896,9 @@ class function:
# TODO not defined in builtins!
__name__: str
__module__: str
__code__: CodeType
if sys.version_info >= (3,):
__qualname__: str
__code__: CodeType
__annotations__: Dict[str, Any]
class list(MutableSequence[_T], Generic[_T]):
@@ -905,7 +925,7 @@ class list(MutableSequence[_T], Generic[_T]):
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[_T]: ...
def __str__(self) -> str: ...
def __hash__(self) -> int: ...
__hash__: None # type: ignore
@overload
def __getitem__(self, i: int) -> _T: ...
@overload
@@ -978,7 +998,10 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
def __setitem__(self, k: _KT, v: _VT) -> None: ...
def __delitem__(self, v: _KT) -> None: ...
def __iter__(self) -> Iterator[_KT]: ...
if sys.version_info >= (3, 8):
def __reversed__(self) -> Iterator[_KT]: ...
def __str__(self) -> str: ...
__hash__: None # type: ignore
class set(MutableSet[_T], Generic[_T]):
def __init__(self, iterable: Iterable[_T] = ...) -> None: ...
@@ -1015,6 +1038,7 @@ class set(MutableSet[_T], Generic[_T]):
def __lt__(self, s: AbstractSet[object]) -> bool: ...
def __ge__(self, s: AbstractSet[object]) -> bool: ...
def __gt__(self, s: AbstractSet[object]) -> bool: ...
__hash__: None # type: ignore
class frozenset(AbstractSet[_T], Generic[_T]):
def __init__(self, iterable: Iterable[_T] = ...) -> None: ...
@@ -1106,8 +1130,6 @@ if sys.version_info < (3,):
if sys.version_info >= (3,):
def ascii(__o: object) -> str: ...
class _SupportsIndex(Protocol):
def __index__(self) -> int: ...
def bin(__number: Union[int, _SupportsIndex]) -> str: ...
if sys.version_info >= (3, 7):
@@ -1124,7 +1146,7 @@ if sys.version_info >= (3, 6):
# See https://github.com/python/typeshed/pull/991#issuecomment-288160993
class _PathLike(Generic[AnyStr]):
def __fspath__(self) -> AnyStr: ...
def compile(source: Union[str, bytes, mod, AST], filename: Union[str, bytes, _PathLike], mode: str, flags: int = ..., dont_inherit: int = ..., optimize: int = ...) -> Any: ...
def compile(source: Union[str, bytes, mod, AST], filename: Union[str, bytes, _PathLike[Any]], mode: str, flags: int = ..., dont_inherit: int = ..., optimize: int = ...) -> Any: ...
elif sys.version_info >= (3,):
def compile(source: Union[str, bytes, mod, AST], filename: Union[str, bytes], mode: str, flags: int = ..., dont_inherit: int = ..., optimize: int = ...) -> Any: ...
else:
@@ -1149,20 +1171,15 @@ if sys.version_info >= (3,):
def filter(__function: Callable[[_T], Any], __iterable: Iterable[_T]) -> Iterator[_T]: ...
else:
@overload
def filter(__function: Callable[[AnyStr], Any], # type: ignore
__iterable: AnyStr) -> AnyStr: ...
def filter(__function: Callable[[AnyStr], Any], __iterable: AnyStr) -> AnyStr: ... # type: ignore
@overload
def filter(__function: None, # type: ignore
__iterable: Tuple[Optional[_T], ...]) -> Tuple[_T, ...]: ...
def filter(__function: None, __iterable: Tuple[Optional[_T], ...]) -> Tuple[_T, ...]: ... # type: ignore
@overload
def filter(__function: Callable[[_T], Any], # type: ignore
__iterable: Tuple[_T, ...]) -> Tuple[_T, ...]: ...
def filter(__function: Callable[[_T], Any], __iterable: Tuple[_T, ...]) -> Tuple[_T, ...]: ... # type: ignore
@overload
def filter(__function: None,
__iterable: Iterable[Optional[_T]]) -> List[_T]: ...
def filter(__function: None, __iterable: Iterable[Optional[_T]]) -> List[_T]: ...
@overload
def filter(__function: Callable[[_T], Any],
__iterable: Iterable[_T]) -> List[_T]: ...
def filter(__function: Callable[[_T], Any], __iterable: Iterable[_T]) -> List[_T]: ...
def format(__o: object, __format_spec: str = ...) -> str: ... # TODO unicode
def getattr(__o: Any, name: Text, __default: Any = ...) -> Any: ...
def globals() -> Dict[str, Any]: ...
@@ -1180,9 +1197,11 @@ else:
@overload
def iter(__iterable: Iterable[_T]) -> Iterator[_T]: ...
@overload
def iter(__function: Callable[[], _T], __sentinel: _T) -> Iterator[_T]: ...
def isinstance(__o: object, __t: Union[type, Tuple[Union[type, Tuple], ...]]) -> bool: ...
def issubclass(__cls: type, __classinfo: Union[type, Tuple[Union[type, Tuple], ...]]) -> bool: ...
def iter(__function: Callable[[], Optional[_T]], __sentinel: None) -> Iterator[_T]: ...
@overload
def iter(__function: Callable[[], _T], __sentinel: Any) -> Iterator[_T]: ...
def isinstance(__o: object, __t: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]) -> bool: ...
def issubclass(__cls: type, __classinfo: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]) -> bool: ...
def len(__o: Sized) -> int: ...
if sys.version_info >= (3,):
def license() -> None: ...
@@ -1318,7 +1337,7 @@ def next(__i: Iterator[_T], default: _VT) -> Union[_T, _VT]: ...
def oct(__i: Union[int, _SupportsIndex]) -> str: ...
if sys.version_info >= (3, 6):
def open(file: Union[str, bytes, int, _PathLike], mode: str = ..., buffering: int = ..., encoding: Optional[str] = ...,
def open(file: Union[str, bytes, int, _PathLike[Any]], mode: str = ..., buffering: int = ..., encoding: Optional[str] = ...,
errors: Optional[str] = ..., newline: Optional[str] = ..., closefd: bool = ...,
opener: Optional[Callable[[str, int], int]] = ...) -> IO[Any]: ...
elif sys.version_info >= (3,):
@@ -1332,12 +1351,16 @@ def ord(__c: Union[Text, bytes]) -> int: ...
if sys.version_info >= (3,):
class _Writer(Protocol):
def write(self, __s: str) -> Any: ...
def print(*values: object, sep: Text = ..., end: Text = ..., file: Optional[_Writer] = ..., flush: bool = ...) -> None: ...
def print(
*values: object, sep: Optional[Text] = ..., end: Optional[Text] = ..., file: Optional[_Writer] = ..., flush: bool = ...
) -> None: ...
else:
class _Writer(Protocol):
def write(self, __s: Any) -> Any: ...
# This is only available after from __future__ import print_function.
def print(*values: object, sep: Text = ..., end: Text = ..., file: Optional[_Writer] = ...) -> None: ...
def print(*values: object, sep: Optional[Text] = ..., end: Optional[Text] = ..., file: Optional[_Writer] = ...) -> None: ...
@overload
def pow(__x: int, __y: int) -> Any: ... # The return type can be int or float, depending on y
@overload
@@ -1370,7 +1393,7 @@ if sys.version_info >= (3,):
@overload
def round(number: SupportsRound[_T]) -> int: ...
@overload
def round(number: SupportsRound[_T], ndigits: None) -> int: ... # type: ignore
def round(number: SupportsRound[_T], ndigits: None) -> int: ...
@overload
def round(number: SupportsRound[_T], ndigits: int) -> _T: ...
else:
@@ -1390,7 +1413,7 @@ if sys.version_info >= (3,):
else:
def sorted(__iterable: Iterable[_T], *,
cmp: Callable[[_T, _T], int] = ...,
key: Callable[[_T], Any] = ...,
key: Optional[Callable[[_T], Any]] = ...,
reverse: bool = ...) -> List[_T]: ...
@overload
def sum(__iterable: Iterable[_T]) -> Union[_T, int]: ...
@@ -1436,8 +1459,10 @@ else:
def zip(__iter1: Iterable[Any], __iter2: Iterable[Any], __iter3: Iterable[Any],
__iter4: Iterable[Any], __iter5: Iterable[Any], __iter6: Iterable[Any],
*iterables: Iterable[Any]) -> List[Tuple[Any, ...]]: ...
def __import__(name: Text, globals: Dict[str, Any] = ..., locals: Dict[str, Any] = ...,
fromlist: List[str] = ..., level: int = ...) -> Any: ...
def __import__(name: Text, globals: Optional[Mapping[str, Any]] = ...,
locals: Optional[Mapping[str, Any]] = ...,
fromlist: Sequence[str] = ...,
level: int = ...) -> Any: ...
# Actually the type of Ellipsis is <type 'ellipsis'>, but since it's
# not exposed anywhere under that name, we make it private here.
@@ -1467,6 +1492,8 @@ class BaseException(object):
__suppress_context__: bool
__traceback__: Optional[TracebackType]
def __init__(self, *args: object) -> None: ...
def __str__(self) -> str: ...
def __repr__(self) -> str: ...
if sys.version_info < (3,):
def __getitem__(self, i: int) -> Any: ...
def __getslice__(self, start: int, stop: int) -> Tuple[Any, ...]: ...
@@ -1508,9 +1535,10 @@ class AttributeError(_StandardError): ...
class BufferError(_StandardError): ...
class EOFError(_StandardError): ...
class ImportError(_StandardError):
if sys.version_info >= (3,):
name: str
path: str
if sys.version_info >= (3, 3):
def __init__(self, *args, name: Optional[str] = ..., path: Optional[str] = ...) -> None: ...
name: Optional[str]
path: Optional[str]
class LookupError(_StandardError): ...
class MemoryError(_StandardError): ...
class NameError(_StandardError): ...
@@ -1523,7 +1551,7 @@ class SyntaxError(_StandardError):
msg: str
lineno: int
offset: Optional[int]
text: str
text: Optional[str]
filename: str
class SystemError(_StandardError): ...
class TypeError(_StandardError): ...
@@ -1612,7 +1640,7 @@ if sys.version_info < (3,):
def next(self) -> str: ...
def read(self, n: int = ...) -> str: ...
def __enter__(self) -> BinaryIO: ...
def __exit__(self, t: Optional[type] = ..., exc: Optional[BaseException] = ..., tb: Optional[Any] = ...) -> bool: ...
def __exit__(self, t: Optional[type] = ..., exc: Optional[BaseException] = ..., tb: Optional[Any] = ...) -> Optional[bool]: ...
def flush(self) -> None: ...
def fileno(self) -> int: ...
def isatty(self) -> bool: ...
+14 -17
View File
@@ -1,18 +1,19 @@
"""Stub file for the '_collections' module."""
from typing import Any, Generic, Iterator, TypeVar, Optional, Union
class defaultdict(dict):
default_factory: None
def __init__(self, default: Any = ..., init: Any = ...) -> None: ...
def __missing__(self, key) -> Any:
raise KeyError()
def __copy__(self) -> defaultdict: ...
def copy(self) -> defaultdict: ...
from typing import Any, Callable, Dict, Generic, Iterator, TypeVar, Optional, Union
_K = TypeVar("_K")
_V = TypeVar("_V")
_T = TypeVar('_T')
_T2 = TypeVar('_T2')
class defaultdict(Dict[_K, _V]):
default_factory: None
def __init__(self, __default_factory: Callable[[], _V] = ..., init: Any = ...) -> None: ...
def __missing__(self, key: _K) -> _V: ...
def __copy__(self: _T) -> _T: ...
def copy(self: _T) -> _T: ...
class deque(Generic[_T]):
maxlen: Optional[int]
def __init__(self, iterable: Iterator[_T] = ..., maxlen: int = ...) -> None: ...
@@ -22,18 +23,14 @@ class deque(Generic[_T]):
def count(self, x: Any) -> int: ...
def extend(self, iterable: Iterator[_T]) -> None: ...
def extendleft(self, iterable: Iterator[_T]) -> None: ...
def pop(self) -> _T:
raise IndexError()
def popleft(self) -> _T:
raise IndexError()
def remove(self, value: _T) -> None:
raise IndexError()
def pop(self) -> _T: ...
def popleft(self) -> _T: ...
def remove(self, value: _T) -> None: ...
def reverse(self) -> None: ...
def rotate(self, n: int = ...) -> None: ...
def __contains__(self, o: Any) -> bool: ...
def __copy__(self) -> deque[_T]: ...
def __getitem__(self, i: int) -> _T:
raise IndexError()
def __getitem__(self, i: int) -> _T: ...
def __iadd__(self, other: deque[_T2]) -> deque[Union[_T, _T2]]: ...
def __iter__(self) -> Iterator[_T]: ...
def __len__(self) -> int: ...
+6 -73
View File
@@ -3,10 +3,6 @@
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Tuple, overload
_T = TypeVar("_T")
_T2 = TypeVar("_T2")
_T3 = TypeVar("_T3")
_T4 = TypeVar("_T4")
_T5 = TypeVar("_T5")
_S = TypeVar("_S")
@overload
@@ -16,72 +12,9 @@ def reduce(function: Callable[[_T, _T], _T],
def reduce(function: Callable[[_T, _S], _T],
sequence: Iterable[_S], initial: _T) -> _T: ...
@overload
def partial(__func: Callable[[_T], _S], __arg: _T) -> Callable[[], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2], _S], __arg: _T) -> Callable[[_T2], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3], _S], __arg: _T) -> Callable[[_T2, _T3], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3, _T4], _S], __arg: _T) -> Callable[[_T2, _T3, _T4], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3, _T4, _T5], _S], __arg: _T) -> Callable[[_T2, _T3, _T4, _T5], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2], _S],
__arg1: _T,
__arg2: _T2) -> Callable[[], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3], _S],
__arg1: _T,
__arg2: _T2) -> Callable[[_T3], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3, _T4], _S],
__arg1: _T,
__arg2: _T2) -> Callable[[_T3, _T4], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3, _T4, _T5], _S],
__arg1: _T,
__arg2: _T2) -> Callable[[_T3, _T4, _T5], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3], _S],
__arg1: _T,
__arg2: _T2,
__arg3: _T3) -> Callable[[], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3, _T4], _S],
__arg1: _T,
__arg2: _T2,
__arg3: _T3) -> Callable[[_T4], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3, _T4, _T5], _S],
__arg1: _T,
__arg2: _T2,
__arg3: _T3) -> Callable[[_T4, _T5], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3, _T4], _S],
__arg1: _T,
__arg2: _T2,
__arg3: _T3,
__arg4: _T4) -> Callable[[], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3, _T4, _T5], _S],
__arg1: _T,
__arg2: _T2,
__arg3: _T3,
__arg4: _T4) -> Callable[[_T5], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3, _T4, _T5], _S],
__arg1: _T,
__arg2: _T2,
__arg3: _T3,
__arg4: _T4,
__arg5: _T5) -> Callable[[], _S]: ...
@overload
def partial(__func: Callable[..., _S],
*args: Any,
**kwargs: Any) -> Callable[..., _S]: ...
class partial(object):
func: Callable[..., Any]
args: Tuple[Any, ...]
keywords: Dict[str, Any]
def __init__(self, func: Callable[..., Any], *args: Any, **kwargs: Any) -> None: ...
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
+6 -16
View File
@@ -6,29 +6,19 @@
from typing import Any, List, Tuple, Dict, Generic
def coverage(a: str) -> Any: ...
def logreader(a: str) -> LogReaderType:
raise IOError()
raise RuntimeError()
def profiler(a: str, *args, **kwargs) -> Any:
raise IOError()
def resolution() -> tuple: ...
def logreader(a: str) -> LogReaderType: ...
def profiler(a: str, *args, **kwargs) -> Any: ...
def resolution() -> Tuple[Any, ...]: ...
class LogReaderType(object):
def close(self) -> None: ...
def fileno(self) -> int:
raise ValueError()
def fileno(self) -> int: ...
class ProfilerType(object):
def addinfo(self, a: str, b: str) -> None: ...
def close(self) -> None: ...
def fileno(self) -> int:
raise ValueError()
def fileno(self) -> int: ...
def runcall(self, *args, **kwargs) -> Any: ...
def runcode(self, a, b, *args, **kwargs) -> Any:
raise TypeError()
def runcode(self, a, b, *args, **kwargs) -> Any: ...
def start(self) -> None: ...
def stop(self) -> None: ...
+17 -14
View File
@@ -16,7 +16,7 @@ _T = TypeVar("_T")
class _IOBase(BinaryIO):
@property
def closed(self) -> bool: ...
def _checkClosed(self) -> None: ...
def _checkClosed(self, msg: Optional[str] = ...) -> None: ... # undocumented
def _checkReadable(self) -> None: ...
def _checkSeekable(self) -> None: ...
def _checkWritable(self) -> None: ...
@@ -32,7 +32,7 @@ class _IOBase(BinaryIO):
def truncate(self, size: Optional[int] = ...) -> int: ...
def writable(self) -> bool: ...
def __enter__(self: _T) -> _T: ...
def __exit__(self, t: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[Any]) -> bool: ...
def __exit__(self, t: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[Any]) -> Optional[bool]: ...
def __iter__(self: _T) -> _T: ...
# The parameter type of writelines[s]() is determined by that of write():
def writelines(self, lines: Iterable[bytes]) -> None: ...
@@ -84,8 +84,8 @@ class BufferedWriter(_BufferedIOBase):
class BytesIO(_BufferedIOBase):
def __init__(self, initial_bytes: bytes = ...) -> None: ...
def __setstate__(self, tuple) -> None: ...
def __getstate__(self) -> tuple: ...
def __setstate__(self, state: Tuple[Any, ...]) -> None: ...
def __getstate__(self) -> Tuple[Any, ...]: ...
# BytesIO does not contain a "name" field. This workaround is necessary
# to allow BytesIO sub-classes to add this field, as it is defined
# as a read-only property on IO[].
@@ -129,7 +129,7 @@ class _TextIOBase(TextIO):
def _checkSeekable(self) -> None: ...
def _checkWritable(self) -> None: ...
def close(self) -> None: ...
def detach(self) -> IO: ...
def detach(self) -> IO[Any]: ...
def fileno(self) -> int: ...
def flush(self) -> None: ...
def isatty(self) -> bool: ...
@@ -146,7 +146,7 @@ class _TextIOBase(TextIO):
def write(self, pbuf: unicode) -> int: ...
def writelines(self, lines: Iterable[unicode]) -> None: ...
def __enter__(self: _T) -> _T: ...
def __exit__(self, t: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[Any]) -> bool: ...
def __exit__(self, t: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[Any]) -> Optional[bool]: ...
def __iter__(self: _T) -> _T: ...
class StringIO(_TextIOBase):
@@ -154,8 +154,8 @@ class StringIO(_TextIOBase):
def __init__(self,
initial_value: Optional[unicode] = ...,
newline: Optional[unicode] = ...) -> None: ...
def __setstate__(self, state: tuple) -> None: ...
def __getstate__(self) -> tuple: ...
def __setstate__(self, state: Tuple[Any, ...]) -> None: ...
def __getstate__(self) -> Tuple[Any, ...]: ...
# StringIO does not contain a "name" field. This workaround is necessary
# to allow StringIO sub-classes to add this field, as it is defined
# as a read-only property on IO[].
@@ -167,12 +167,15 @@ class TextIOWrapper(_TextIOBase):
line_buffering: bool
buffer: BinaryIO
_CHUNK_SIZE: int
def __init__(self, buffer: IO,
encoding: Optional[Text] = ...,
errors: Optional[Text] = ...,
newline: Optional[Text] = ...,
line_buffering: bool = ...,
write_through: bool = ...) -> None: ...
def __init__(
self,
buffer: IO[Any],
encoding: Optional[Text] = ...,
errors: Optional[Text] = ...,
newline: Optional[Text] = ...,
line_buffering: bool = ...,
write_through: bool = ...,
) -> None: ...
def open(file: Union[str, unicode, int],
mode: Text = ...,
+3 -13
View File
@@ -1,17 +1,7 @@
"""Stub file for the '_json' module."""
# This is an autogenerated file. It serves as a starting point
# for a more precise manual annotation of this module.
# Feel free to edit the source below, but remove this header when you do.
from typing import Any, List, Tuple, Dict, Generic
def encode_basestring_ascii(*args, **kwargs) -> str:
raise TypeError()
def scanstring(a, b, *args, **kwargs) -> tuple:
raise TypeError()
from typing import Any, List, Tuple, Dict, Generic, Tuple
def encode_basestring_ascii(*args, **kwargs) -> str: ...
def scanstring(a, b, *args, **kwargs) -> Tuple[Any, ...]: ...
class Encoder(object): ...
class Scanner(object): ...
+10 -14
View File
@@ -253,34 +253,30 @@ class SocketType(object):
timeout: float
def __init__(self, family: int = ..., type: int = ..., proto: int = ...) -> None: ...
def accept(self) -> Tuple[SocketType, tuple]: ...
def bind(self, address: tuple) -> None: ...
def accept(self) -> Tuple[SocketType, Tuple[Any, ...]]: ...
def bind(self, address: Tuple[Any, ...]) -> None: ...
def close(self) -> None: ...
def connect(self, address: tuple) -> None:
raise gaierror
raise timeout
def connect_ex(self, address: tuple) -> int: ...
def connect(self, address: Tuple[Any, ...]) -> None: ...
def connect_ex(self, address: Tuple[Any, ...]) -> int: ...
def dup(self) -> SocketType: ...
def fileno(self) -> int: ...
def getpeername(self) -> tuple: ...
def getsockname(self) -> tuple: ...
def getpeername(self) -> Tuple[Any, ...]: ...
def getsockname(self) -> Tuple[Any, ...]: ...
def getsockopt(self, level: int, option: int, buffersize: int = ...) -> str: ...
def gettimeout(self) -> float: ...
def listen(self, backlog: int) -> None:
raise error
def listen(self, backlog: int) -> None: ...
def makefile(self, mode: str = ..., buffersize: int = ...) -> IO[Any]: ...
def recv(self, buffersize: int, flags: int = ...) -> str: ...
def recv_into(self, buffer: bytearray, nbytes: int = ..., flags: int = ...) -> int: ...
def recvfrom(self, buffersize: int, flags: int = ...) -> tuple:
raise error
def recvfrom(self, buffersize: int, flags: int = ...) -> Tuple[Any, ...]: ...
def recvfrom_into(self, buffer: bytearray, nbytes: int = ...,
flags: int = ...) -> int: ...
def send(self, data: str, flags: int = ...) -> int: ...
def sendall(self, data: str, flags: int = ...) -> None: ...
@overload
def sendto(self, data: str, address: tuple) -> int: ...
def sendto(self, data: str, address: Tuple[Any, ...]) -> int: ...
@overload
def sendto(self, data: str, flags: int, address: tuple) -> int: ...
def sendto(self, data: str, flags: int, address: Tuple[Any, ...]) -> int: ...
def setblocking(self, flag: bool) -> None: ...
def setsockopt(self, level: int, option: int, value: Union[int, str]) -> None: ...
def settimeout(self, value: Optional[float]) -> None: ...
+17 -15
View File
@@ -8,10 +8,8 @@ MAXREPEAT: long
copyright: str
class SRE_Match(object):
def start(self, group: int = ...) -> int:
raise IndexError()
def end(self, group: int = ...) -> int:
raise IndexError()
def start(self, group: int = ...) -> int: ...
def end(self, group: int = ...) -> int: ...
def expand(self, s: str) -> Any: ...
@overload
def group(self) -> str: ...
@@ -19,8 +17,9 @@ class SRE_Match(object):
def group(self, group: int = ...) -> Optional[str]: ...
def groupdict(self) -> Dict[int, Optional[str]]: ...
def groups(self) -> Tuple[Optional[str], ...]: ...
def span(self) -> Tuple[int, int]:
raise IndexError()
def span(self) -> Tuple[int, int]: ...
@property
def regs(self) -> Tuple[Tuple[int, int], ...]: ... # undocumented
class SRE_Scanner(object):
pattern: str
@@ -33,20 +32,23 @@ class SRE_Pattern(object):
groups: int
groupindex: Mapping[str, int]
indexgroup: Sequence[int]
def findall(self, source: str, pos: int = ..., endpos: int = ...) -> List[Union[tuple, str]]: ...
def finditer(self, source: str, pos: int = ..., endpos: int = ...) -> Iterable[Union[tuple, str]]: ...
def findall(self, source: str, pos: int = ..., endpos: int = ...) -> List[Union[Tuple[Any, ...], str]]: ...
def finditer(self, source: str, pos: int = ..., endpos: int = ...) -> Iterable[Union[Tuple[Any, ...], str]]: ...
def match(self, pattern, pos: int = ..., endpos: int = ...) -> SRE_Match: ...
def scanner(self, s: str, start: int = ..., end: int = ...) -> SRE_Scanner: ...
def search(self, pattern, pos: int = ..., endpos: int = ...) -> SRE_Match: ...
def split(self, source: str, maxsplit: int = ...) -> List[Optional[str]]: ...
def sub(self, repl: str, string: str, count: int = ...) -> tuple: ...
def subn(self, repl: str, string: str, count: int = ...) -> tuple: ...
def sub(self, repl: str, string: str, count: int = ...) -> Tuple[Any, ...]: ...
def subn(self, repl: str, string: str, count: int = ...) -> Tuple[Any, ...]: ...
def compile(pattern: str, flags: int, code: List[int],
groups: int = ...,
groupindex: Mapping[str, int] = ...,
indexgroup: Sequence[int] = ...) -> SRE_Pattern:
raise OverflowError()
def compile(
pattern: str,
flags: int,
code: List[int],
groups: int = ...,
groupindex: Mapping[str, int] = ...,
indexgroup: Sequence[int] = ...,
) -> SRE_Pattern: ...
def getcodesize() -> int: ...
+1 -3
View File
@@ -1,7 +1,5 @@
# Source: https://hg.python.org/cpython/file/2.7/Lib/_threading_local.py
from typing import Any, List
__all__: List[str]
from typing import Any
class _localbase(object): ...
-11
View File
@@ -1,11 +0,0 @@
from typing import Any, List, Optional, Type
default_action: str
filters: List[tuple]
once_registry: dict
def warn(message: Warning, category: Optional[Type[Warning]] = ..., stacklevel: int = ...) -> None: ...
def warn_explicit(message: Warning, category: Optional[Type[Warning]],
filename: str, lineno: int,
module: Any = ..., registry: dict = ...,
module_globals: dict = ...) -> None: ...
+7 -5
View File
@@ -1,18 +1,20 @@
from typing import Any, Dict, Set, Tuple, Type
from typing import Any, Callable, Dict, Set, Tuple, Type, TypeVar
import _weakrefset
_FuncT = TypeVar('_FuncT', bound=Callable[..., Any])
# NOTE: mypy has special processing for ABCMeta and abstractmethod.
def abstractmethod(funcobj: Any) -> Any: ...
def abstractmethod(funcobj: _FuncT) -> _FuncT: ...
class ABCMeta(type):
# TODO: FrozenSet
__abstractmethods__: Set[Any]
_abc_cache: _weakrefset.WeakSet
_abc_cache: _weakrefset.WeakSet[Any]
_abc_invalidation_counter: int
_abc_negative_cache: _weakrefset.WeakSet
_abc_negative_cache: _weakrefset.WeakSet[Any]
_abc_negative_cache_version: int
_abc_registry: _weakrefset.WeakSet
_abc_registry: _weakrefset.WeakSet[Any]
def __init__(self, name: str, bases: Tuple[type, ...], namespace: Dict[Any, Any]) -> None: ...
def __instancecheck__(cls: ABCMeta, instance: Any) -> Any: ...
def __subclasscheck__(cls: ABCMeta, subclass: Any) -> Any: ...
+5 -11
View File
@@ -1,5 +1,5 @@
# These are not exported.
from typing import Dict, Generic, TypeVar, Tuple, overload, Type, Optional, List, Union, Reversible
from typing import Any, Dict, Generic, TypeVar, Tuple, overload, Type, Optional, List, Union, Reversible
# These are exported.
from typing import (
@@ -28,7 +28,7 @@ _VT = TypeVar('_VT')
# namedtuple is special-cased in the type checker; the initializer is ignored.
def namedtuple(typename: Union[str, unicode], field_names: Union[str, unicode, Iterable[Union[str, unicode]]],
verbose: bool = ..., rename: bool = ...) -> Type[tuple]: ...
verbose: bool = ..., rename: bool = ...) -> Type[Tuple[Any, ...]]: ...
class deque(Sized, Iterable[_T], Reversible[_T], Generic[_T]):
def __init__(self, iterable: Iterable[_T] = ...,
@@ -56,8 +56,6 @@ class deque(Sized, Iterable[_T], Reversible[_T], Generic[_T]):
def __reversed__(self) -> Iterator[_T]: ...
def __iadd__(self: _S, iterable: Iterable[_T]) -> _S: ...
_CounterT = TypeVar('_CounterT', bound=Counter)
class Counter(Dict[_T, int], Generic[_T]):
@overload
def __init__(self, **kwargs: int) -> None: ...
@@ -65,7 +63,7 @@ class Counter(Dict[_T, int], Generic[_T]):
def __init__(self, mapping: Mapping[_T, int]) -> None: ...
@overload
def __init__(self, iterable: Iterable[_T]) -> None: ...
def copy(self: _CounterT) -> _CounterT: ...
def copy(self: _S) -> _S: ...
def elements(self) -> Iterator[_T]: ...
def most_common(self, n: Optional[int] = ...) -> List[Tuple[_T, int]]: ...
@overload
@@ -93,15 +91,11 @@ class Counter(Dict[_T, int], Generic[_T]):
def __iand__(self, other: Counter[_T]) -> Counter[_T]: ...
def __ior__(self, other: Counter[_T]) -> Counter[_T]: ...
_OrderedDictT = TypeVar('_OrderedDictT', bound=OrderedDict)
class OrderedDict(Dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]):
def popitem(self, last: bool = ...) -> Tuple[_KT, _VT]: ...
def copy(self: _OrderedDictT) -> _OrderedDictT: ...
def copy(self: _S) -> _S: ...
def __reversed__(self) -> Iterator[_KT]: ...
_DefaultDictT = TypeVar('_DefaultDictT', bound=defaultdict)
class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]):
default_factory: Callable[[], _VT]
@overload
@@ -123,4 +117,4 @@ class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]):
def __init__(self, default_factory: Optional[Callable[[], _VT]],
iterable: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ...
def __missing__(self, key: _KT) -> _VT: ...
def copy(self: _DefaultDictT) -> _DefaultDictT: ...
def copy(self: _S) -> _S: ...
+12 -3
View File
@@ -1,10 +1,19 @@
# Stubs for compileall (Python 2)
from typing import Optional, Pattern, Union
from typing import Any, Optional, Pattern, Union
_Path = Union[str, bytes]
# rx can be any object with a 'search' method; once we have Protocols we can change the type
def compile_dir(dir: _Path, maxlevels: int = ..., ddir: Optional[_Path] = ..., force: bool = ..., rx: Optional[Pattern] = ..., quiet: int = ...) -> int: ...
def compile_file(fullname: _Path, ddir: Optional[_Path] = ..., force: bool = ..., rx: Optional[Pattern] = ..., quiet: int = ...) -> int: ...
def compile_dir(
dir: _Path,
maxlevels: int = ...,
ddir: Optional[_Path] = ...,
force: bool = ...,
rx: Optional[Pattern[Any]] = ...,
quiet: int = ...,
) -> int: ...
def compile_file(
fullname: _Path, ddir: Optional[_Path] = ..., force: bool = ..., rx: Optional[Pattern[Any]] = ..., quiet: int = ...,
) -> int: ...
def compile_path(skip_curdir: bool = ..., maxlevels: int = ..., force: bool = ..., quiet: int = ...) -> int: ...
+3 -1
View File
@@ -105,6 +105,8 @@ class FileCookieJar(CookieJar):
def load(self, filename: Optional[Any] = ..., ignore_discard: bool = ..., ignore_expires: bool = ...): ...
def revert(self, filename: Optional[Any] = ..., ignore_discard: bool = ..., ignore_expires: bool = ...): ...
class LWPCookieJar(FileCookieJar):
def as_lwp_str(self, ignore_discard: bool = ..., ignore_expires: bool = ...) -> str: ... # undocumented
MozillaCookieJar = FileCookieJar
LWPCookieJar = FileCookieJar
def lwp_cookie_str(cookie: Cookie) -> str: ...
+14
View File
@@ -0,0 +1,14 @@
from typing import TypeVar, Callable, Union, Tuple, Any, Optional, SupportsInt, Hashable, List
_Type = TypeVar("_Type", bound=type)
_Reduce = Union[Tuple[Callable[..., _Type], Tuple[Any, ...]], Tuple[Callable[..., _Type], Tuple[Any, ...], Optional[Any]]]
__all__: List[str]
def pickle(ob_type: _Type, pickle_function: Callable[[_Type], Union[str, _Reduce[_Type]]], constructor_ob: Optional[Callable[[_Reduce[_Type]], _Type]] = ...) -> None: ...
def constructor(object: Callable[[_Reduce[_Type]], _Type]) -> None: ...
def add_extension(module: Hashable, name: Hashable, code: SupportsInt) -> None: ...
def remove_extension(module: Hashable, name: Hashable, code: int) -> None: ...
def clear_extension_cache() -> None: ...
+4 -4
View File
@@ -1,5 +1,5 @@
from typing import Generator
from typing import Any, Generator
def walk(self) -> Generator: ...
def body_line_iterator(msg, decode: bool = ...) -> Generator: ...
def typed_subpart_iterator(msg, maintype=..., subtype=...) -> Generator: ...
def walk(self) -> Generator[Any, Any, Any]: ...
def body_line_iterator(msg, decode: bool = ...) -> Generator[Any, Any, Any]: ...
def typed_subpart_iterator(msg, maintype=..., subtype=...) -> Generator[Any, Any, Any]: ...
+2 -2
View File
@@ -1,4 +1,4 @@
from typing import Generator
from typing import Any, Generator
class Message:
preamble = ...
@@ -42,4 +42,4 @@ class Message:
def set_boundary(self, boundary) -> None: ...
def get_content_charset(self, failobj=...): ...
def get_charsets(self, failobj=...): ...
def walk(self) -> Generator: ...
def walk(self) -> Generator[Any, Any, Any]: ...
+6 -74
View File
@@ -4,15 +4,10 @@
from abc import ABCMeta, abstractmethod
from typing import Any, Callable, Generic, Dict, Iterable, Optional, Sequence, Tuple, TypeVar, overload
from collections import namedtuple
_AnyCallable = Callable[..., Any]
_T = TypeVar("_T")
_T2 = TypeVar("_T2")
_T3 = TypeVar("_T3")
_T4 = TypeVar("_T4")
_T5 = TypeVar("_T5")
_S = TypeVar("_S")
@overload
def reduce(function: Callable[[_T, _T], _T],
@@ -30,72 +25,9 @@ def wraps(wrapped: _AnyCallable, assigned: Sequence[str] = ..., updated: Sequenc
def total_ordering(cls: type) -> type: ...
def cmp_to_key(mycmp: Callable[[_T, _T], int]) -> Callable[[_T], Any]: ...
@overload
def partial(__func: Callable[[_T], _S], __arg: _T) -> Callable[[], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2], _S], __arg: _T) -> Callable[[_T2], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3], _S], __arg: _T) -> Callable[[_T2, _T3], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3, _T4], _S], __arg: _T) -> Callable[[_T2, _T3, _T4], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3, _T4, _T5], _S], __arg: _T) -> Callable[[_T2, _T3, _T4, _T5], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2], _S],
__arg1: _T,
__arg2: _T2) -> Callable[[], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3], _S],
__arg1: _T,
__arg2: _T2) -> Callable[[_T3], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3, _T4], _S],
__arg1: _T,
__arg2: _T2) -> Callable[[_T3, _T4], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3, _T4, _T5], _S],
__arg1: _T,
__arg2: _T2) -> Callable[[_T3, _T4, _T5], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3], _S],
__arg1: _T,
__arg2: _T2,
__arg3: _T3) -> Callable[[], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3, _T4], _S],
__arg1: _T,
__arg2: _T2,
__arg3: _T3) -> Callable[[_T4], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3, _T4, _T5], _S],
__arg1: _T,
__arg2: _T2,
__arg3: _T3) -> Callable[[_T4, _T5], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3, _T4], _S],
__arg1: _T,
__arg2: _T2,
__arg3: _T3,
__arg4: _T4) -> Callable[[], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3, _T4, _T5], _S],
__arg1: _T,
__arg2: _T2,
__arg3: _T3,
__arg4: _T4) -> Callable[[_T5], _S]: ...
@overload
def partial(__func: Callable[[_T, _T2, _T3, _T4, _T5], _S],
__arg1: _T,
__arg2: _T2,
__arg3: _T3,
__arg4: _T4,
__arg5: _T5) -> Callable[[], _S]: ...
@overload
def partial(__func: Callable[..., _S],
*args: Any,
**kwargs: Any) -> Callable[..., _S]: ...
class partial(Generic[_T]):
func = ... # Callable[..., _T]
args: Tuple[Any, ...]
keywords: Dict[str, Any]
def __init__(self, func: Callable[..., _T], *args: Any, **kwargs: Any) -> None: ...
def __call__(self, *args: Any, **kwargs: Any) -> _T: ...
+3 -3
View File
@@ -6,9 +6,9 @@ _DataType = Union[str, unicode, bytearray, buffer, memoryview]
class _hash(object): # This is not actually in the module namespace.
name: str
block_size = 0
digest_size = 0
digestsize = 0
block_size: int
digest_size: int
digestsize: int
def __init__(self, arg: _DataType = ...) -> None: ...
def update(self, arg: _DataType) -> None: ...
def digest(self) -> str: ...
+9 -7
View File
@@ -1,16 +1,18 @@
from typing import TypeVar, List, Iterable, Any, Callable, Optional
from typing import TypeVar, List, Iterable, Any, Callable, Optional, Protocol
_T = TypeVar('_T')
class _Sortable(Protocol):
def __lt__(self: _T, other: _T) -> bool: ...
def cmp_lt(x, y) -> bool: ...
def heappush(heap: List[_T], item: _T) -> None: ...
def heappop(heap: List[_T]) -> _T:
raise IndexError() # if heap is empty
def heappop(heap: List[_T]) -> _T: ...
def heappushpop(heap: List[_T], item: _T) -> _T: ...
def heapify(x: List[_T]) -> None: ...
def heapreplace(heap: List[_T], item: _T) -> _T:
raise IndexError() # if heap is empty
def heapreplace(heap: List[_T], item: _T) -> _T: ...
def merge(*iterables: Iterable[_T]) -> Iterable[_T]: ...
def nlargest(n: int, iterable: Iterable[_T],
key: Optional[Callable[[_T], Any]] = ...) -> List[_T]: ...
def nsmallest(n: int, iterable: Iterable[_T]) -> List[_T]: ...
key: Optional[Callable[[_T], _Sortable]] = ...) -> List[_T]: ...
def nsmallest(n: int, iterable: Iterable[_T],
key: Optional[Callable[[_T], _Sortable]] = ...) -> List[_T]: ...
+4 -4
View File
@@ -1,5 +1,5 @@
from typing import Any, Mapping
from typing import Dict
name2codepoint: Mapping[str, int]
codepoint2name: Mapping[int, str]
entitydefs: Mapping[str, str]
name2codepoint: Dict[str, int]
codepoint2name: Dict[int, str]
entitydefs: Dict[str, str]
+1 -1
View File
@@ -15,7 +15,7 @@ PY_SOURCE: int
SEARCH_ERROR: int
def acquire_lock() -> None: ...
def find_module(name: str, path: Iterable[str] = ...) -> Optional[Tuple[str, str, Tuple[str, str, int]]]: ...
def find_module(name: str, path: Iterable[str] = ...) -> Optional[Tuple[IO[Any], str, Tuple[str, str, int]]]: ...
def get_magic() -> str: ...
def get_suffixes() -> List[Tuple[str, str, int]]: ...
def init_builtin(name: str) -> types.ModuleType: ...
+45 -51
View File
@@ -1,4 +1,4 @@
from types import CodeType, TracebackType, FrameType, ModuleType
from types import CodeType, TracebackType, FrameType, FunctionType, MethodType, ModuleType
from typing import Any, Dict, Callable, List, NamedTuple, Optional, Sequence, Tuple, Type, Union
# Types and members
@@ -22,11 +22,12 @@ CO_VARARGS: int
CO_VARKEYWORDS: int
TPFLAGS_IS_ABSTRACT: int
ModuleInfo = NamedTuple('ModuleInfo', [('name', str),
('suffix', str),
('mode', str),
('module_type', int),
])
class ModuleInfo(NamedTuple):
name: str
suffix: str
mode: str
module_type: int
def getmembers(
object: object,
predicate: Optional[Callable[[Any], bool]] = ...
@@ -52,43 +53,40 @@ def isgetsetdescriptor(object: object) -> bool: ...
def ismemberdescriptor(object: object) -> bool: ...
# Retrieving source code
def findsource(object: object) -> Tuple[List[str], int]: ...
def getabsfile(object: object) -> str: ...
_SourceObjectType = Union[ModuleType, Type[Any], MethodType, FunctionType, TracebackType, FrameType, CodeType, Callable[..., Any]]
def findsource(object: _SourceObjectType) -> Tuple[List[str], int]: ...
def getabsfile(object: _SourceObjectType) -> str: ...
def getblock(lines: Sequence[str]) -> Sequence[str]: ...
def getdoc(object: object) -> str: ...
def getcomments(object: object) -> str: ...
def getfile(object: object) -> str: ...
def getmodule(object: object) -> ModuleType: ...
def getsourcefile(object: object) -> str: ...
# TODO restrict to "module, class, method, function, traceback, frame,
# or code object"
def getsourcelines(object: object) -> Tuple[List[str], int]: ...
# TODO restrict to "a module, class, method, function, traceback, frame,
# or code object"
def getsource(object: object) -> str: ...
def getdoc(object: object) -> Optional[str]: ...
def getcomments(object: object) -> Optional[str]: ...
def getfile(object: _SourceObjectType) -> str: ...
def getmodule(object: object) -> Optional[ModuleType]: ...
def getsourcefile(object: _SourceObjectType) -> Optional[str]: ...
def getsourcelines(object: _SourceObjectType) -> Tuple[List[str], int]: ...
def getsource(object: _SourceObjectType) -> str: ...
def cleandoc(doc: str) -> str: ...
def indentsize(line: str) -> int: ...
# Classes and functions
def getclasstree(classes: List[type], unique: bool = ...) -> List[
Union[Tuple[type, Tuple[type, ...]], list]]: ...
def getclasstree(classes: List[type], unique: bool = ...) -> List[Union[Tuple[type, Tuple[type, ...]], List[Any]]]: ...
ArgSpec = NamedTuple('ArgSpec', [('args', List[str]),
('varargs', Optional[str]),
('keywords', Optional[str]),
('defaults', tuple),
])
class ArgSpec(NamedTuple):
args: List[str]
varargs: Optional[str]
keywords: Optional[str]
defaults: Tuple[Any, ...]
ArgInfo = NamedTuple('ArgInfo', [('args', List[str]),
('varargs', Optional[str]),
('keywords', Optional[str]),
('locals', Dict[str, Any]),
])
class ArgInfo(NamedTuple):
args: List[str]
varargs: Optional[str]
keywords: Optional[str]
locals: Dict[str, Any]
Arguments = NamedTuple('Arguments', [('args', List[Union[str, List[Any]]]),
('varargs', Optional[str]),
('keywords', Optional[str]),
])
class Arguments(NamedTuple):
args: List[Union[str, List[Any]]]
varargs: Optional[str]
keywords: Optional[str]
def getargs(co: CodeType) -> Arguments: ...
def getargspec(func: object) -> ArgSpec: ...
@@ -104,18 +102,14 @@ def getcallargs(func, *args, **kwds) -> Dict[str, Any]: ...
# The interpreter stack
Traceback = NamedTuple(
'Traceback',
[
('filename', str),
('lineno', int),
('function', str),
('code_context', List[str]),
('index', int),
]
)
class Traceback(NamedTuple):
filename: str
lineno: int
function: str
code_context: Optional[List[str]]
index: Optional[int] # type: ignore
_FrameInfo = Tuple[FrameType, str, int, str, List[str], int]
_FrameInfo = Tuple[FrameType, str, int, str, Optional[List[str]], Optional[int]]
def getouterframes(frame: FrameType, context: int = ...) -> List[_FrameInfo]: ...
def getframeinfo(frame: Union[FrameType, TracebackType], context: int = ...) -> Traceback: ...
@@ -126,10 +120,10 @@ def currentframe(depth: int = ...) -> FrameType: ...
def stack(context: int = ...) -> List[_FrameInfo]: ...
def trace(context: int = ...) -> List[_FrameInfo]: ...
Attribute = NamedTuple('Attribute', [('name', str),
('kind', str),
('defining_class', type),
('object', object),
])
class Attribute(NamedTuple):
name: str
kind: str
defining_class: type
object: object
def classify_class_attrs(cls: type) -> List[Attribute]: ...
-2
View File
@@ -14,8 +14,6 @@ def cycle(iterable: Iterable[_T]) -> Iterator[_T]: ...
def repeat(object: _T, times: int = ...) -> Iterator[_T]: ...
def accumulate(iterable: Iterable[_T]) -> Iterator[_T]: ...
class chain(Iterator[_T], Generic[_T]):
def __init__(self, *iterables: Iterable[_T]) -> None: ...
def next(self) -> _T: ...
+7 -7
View File
@@ -1,4 +1,4 @@
from typing import Any, IO, Optional, Tuple, Callable, Dict, List, Union, Text, Protocol
from typing import Any, IO, Optional, Tuple, Callable, Dict, List, Union, Text, Protocol, Type
class JSONDecodeError(ValueError):
def dumps(self, obj: Any) -> str: ...
@@ -11,7 +11,7 @@ def dumps(obj: Any,
ensure_ascii: bool = ...,
check_circular: bool = ...,
allow_nan: bool = ...,
cls: Any = ...,
cls: Optional[Type[JSONEncoder]] = ...,
indent: Optional[int] = ...,
separators: Optional[Tuple[str, str]] = ...,
encoding: str = ...,
@@ -25,7 +25,7 @@ def dump(obj: Any,
ensure_ascii: bool = ...,
check_circular: bool = ...,
allow_nan: bool = ...,
cls: Any = ...,
cls: Optional[Type[JSONEncoder]] = ...,
indent: Optional[int] = ...,
separators: Optional[Tuple[str, str]] = ...,
encoding: str = ...,
@@ -35,8 +35,8 @@ def dump(obj: Any,
def loads(s: Union[Text, bytes],
encoding: Any = ...,
cls: Any = ...,
object_hook: Optional[Callable[[Dict], Any]] = ...,
cls: Optional[Type[JSONDecoder]] = ...,
object_hook: Optional[Callable[[Dict[Any, Any]], Any]] = ...,
parse_float: Optional[Callable[[str], Any]] = ...,
parse_int: Optional[Callable[[str], Any]] = ...,
parse_constant: Optional[Callable[[str], Any]] = ...,
@@ -48,8 +48,8 @@ class _Reader(Protocol):
def load(fp: _Reader,
encoding: Optional[str] = ...,
cls: Any = ...,
object_hook: Optional[Callable[[Dict], Any]] = ...,
cls: Optional[Type[JSONDecoder]] = ...,
object_hook: Optional[Callable[[Dict[Any, Any]], Any]] = ...,
parse_float: Optional[Callable[[str], Any]] = ...,
parse_int: Optional[Callable[[str], Any]] = ...,
parse_constant: Optional[Callable[[str], Any]] = ...,
+2 -2
View File
@@ -2,5 +2,5 @@
from hashlib import md5 as md5, md5 as new
blocksize = 0
digest_size = 0
blocksize: int
digest_size: int
+3 -3
View File
@@ -14,7 +14,7 @@ from Queue import Queue
class DummyProcess(threading.Thread):
_children: weakref.WeakKeyDictionary
_children: weakref.WeakKeyDictionary[Any, Any]
_parent: threading.Thread
_pid: None
_start_called: bool
@@ -42,10 +42,10 @@ class Value(object):
JoinableQueue = Queue
def Array(typecode, sequence, lock=...) -> array.array: ...
def Array(typecode, sequence, lock=...) -> array.array[Any]: ...
def Manager() -> Any: ...
def Pool(processes=..., initializer=..., initargs=...) -> Any: ...
def active_children() -> List: ...
def active_children() -> List[Any]: ...
def current_process() -> threading.Thread: ...
def freeze_support() -> None: ...
def shutdown() -> None: ...
@@ -15,7 +15,7 @@ class Connection(object):
def poll(self, timeout=...) -> Any: ...
class Listener(object):
_backlog_queue: Optional[Queue]
_backlog_queue: Optional[Queue[Any]]
address: Any
def __init__(self, address=..., family=..., backlog=...) -> None: ...
def accept(self) -> Connection: ...
+2 -3
View File
@@ -1,13 +1,12 @@
# Source: https://hg.python.org/cpython/file/2.7/Lib/mutex.py
from collections import deque
from typing import Any, Callable, TypeVar
from typing import Any, Callable, Deque, TypeVar
_ArgType = TypeVar('_ArgType')
class mutex:
locked: bool
queue: deque
queue: Deque[Any]
def __init__(self) -> None: ...
def test(self) -> bool: ...
def testandset(self) -> bool: ...
+13 -24
View File
@@ -3,7 +3,7 @@
from builtins import OSError as error
from io import TextIOWrapper as _TextIOWrapper
from posix import stat_result as stat_result # TODO: use this, see https://github.com/python/mypy/issues/3078
from posix import listdir as listdir, stat_result as stat_result # TODO: use this, see https://github.com/python/mypy/issues/3078
import sys
from typing import (
Mapping, MutableMapping, Dict, List, Any, Tuple, Iterator, overload, Union, AnyStr,
@@ -136,10 +136,17 @@ if sys.version_info >= (3, 6):
_PathType = path._PathType
_StatVFS = NamedTuple('_StatVFS', [('f_bsize', int), ('f_frsize', int), ('f_blocks', int),
('f_bfree', int), ('f_bavail', int), ('f_files', int),
('f_ffree', int), ('f_favail', int), ('f_flag', int),
('f_namemax', int)])
class _StatVFS(NamedTuple):
f_bsize: int
f_frsize: int
f_blocks: int
f_bfree: int
f_bavail: int
f_files: int
f_ffree: int
f_favail: int
f_flag: int
f_namemax: int
def getlogin() -> str: ...
def getpid() -> int: ...
@@ -192,7 +199,7 @@ def lseek(fd: int, pos: int, how: int) -> int: ...
def open(file: _PathType, flags: int, mode: int = ...) -> int: ...
def pipe() -> Tuple[int, int]: ...
def read(fd: int, n: int) -> bytes: ...
def write(fd: int, string: bytes) -> int: ...
def write(fd: int, string: Union[bytes, buffer]) -> int: ...
def access(path: _PathType, mode: int) -> bool: ...
def chdir(path: _PathType) -> None: ...
def fchdir(fd: int) -> None: ...
@@ -200,7 +207,6 @@ def getcwd() -> str: ...
def getcwdu() -> unicode: ...
def chmod(path: _PathType, mode: int) -> None: ...
def link(src: _PathType, link_name: _PathType) -> None: ...
def listdir(path: AnyStr) -> List[AnyStr]: ...
def lstat(path: _PathType) -> Any: ...
def mknod(filename: _PathType, mode: int = ..., device: int = ...) -> None: ...
def major(device: int) -> int: ...
@@ -350,20 +356,3 @@ if sys.version_info < (3, 0):
P_ALL: int
WEXITED: int
WNOWAIT: int
if sys.version_info >= (3, 3):
if sys.platform != 'win32':
# Unix only
def sync() -> None: ...
def truncate(path: Union[_PathType, int], length: int) -> None: ... # Unix only up to version 3.4
def fwalk(top: AnyStr = ..., topdown: bool = ...,
onerror: Callable = ..., *, follow_symlinks: bool = ...,
dir_fd: int = ...) -> Iterator[Tuple[AnyStr, List[AnyStr], List[AnyStr], int]]: ...
terminal_size = NamedTuple('terminal_size', [('columns', int), ('lines', int)])
def get_terminal_size(fd: int = ...) -> terminal_size: ...
if sys.version_info >= (3, 4):
def cpu_count() -> Optional[int]: ...
+1 -4
View File
@@ -4,10 +4,7 @@
import os
import sys
from typing import (
overload, List, Any, AnyStr, Sequence, Tuple, BinaryIO, TextIO,
TypeVar, Union, Text, Callable, Optional
)
from typing import overload, List, Any, AnyStr, Sequence, Tuple, TypeVar, Union, Text, Callable, Optional
_T = TypeVar('_T')
+1 -4
View File
@@ -4,10 +4,7 @@
import os
import sys
from typing import (
overload, List, Any, AnyStr, Sequence, Tuple, BinaryIO, TextIO,
TypeVar, Union, Text, Callable, Optional
)
from typing import overload, List, Any, AnyStr, Sequence, Tuple, TypeVar, Union, Text, Callable, Optional
_T = TypeVar('_T')
+7 -7
View File
@@ -5,24 +5,24 @@ _T = TypeVar('_T')
class Popen3:
sts: int
cmd: Iterable
cmd: Iterable[Any]
pid: int
tochild: TextIO
fromchild: TextIO
childerr: Optional[TextIO]
def __init__(self, cmd: Iterable = ..., capturestderr: bool = ..., bufsize: int = ...) -> None: ...
def __init__(self, cmd: Iterable[Any] = ..., capturestderr: bool = ..., bufsize: int = ...) -> None: ...
def __del__(self) -> None: ...
def poll(self, _deadstate: _T = ...) -> Union[int, _T]: ...
def wait(self) -> int: ...
class Popen4(Popen3):
childerr: None
cmd: Iterable
cmd: Iterable[Any]
pid: int
tochild: TextIO
fromchild: TextIO
def __init__(self, cmd: Iterable = ..., bufsize: int = ...) -> None: ...
def __init__(self, cmd: Iterable[Any] = ..., bufsize: int = ...) -> None: ...
def popen2(cmd: Iterable = ..., bufsize: int = ..., mode: str = ...) -> Tuple[TextIO, TextIO]: ...
def popen3(cmd: Iterable = ..., bufsize: int = ..., mode: str = ...) -> Tuple[TextIO, TextIO, TextIO]: ...
def popen4(cmd: Iterable = ..., bufsize: int = ..., mode: str = ...) -> Tuple[TextIO, TextIO]: ...
def popen2(cmd: Iterable[Any] = ..., bufsize: int = ..., mode: str = ...) -> Tuple[TextIO, TextIO]: ...
def popen3(cmd: Iterable[Any] = ..., bufsize: int = ..., mode: str = ...) -> Tuple[TextIO, TextIO, TextIO]: ...
def popen4(cmd: Iterable[Any] = ..., bufsize: int = ..., mode: str = ...) -> Tuple[TextIO, TextIO]: ...
+9 -13
View File
@@ -1,4 +1,4 @@
from typing import Dict, List, Mapping, Tuple, Union, Sequence, IO, Optional, TypeVar
from typing import AnyStr, Dict, List, Mapping, Tuple, Union, Sequence, IO, Optional, TypeVar
error = OSError
@@ -7,6 +7,8 @@ environ: Dict[str, str]
pathconf_names: Dict[str, int]
sysconf_names: Dict[str, int]
_T = TypeVar("_T")
EX_CANTCREAT: int
EX_CONFIG: int
EX_DATAERR: int
@@ -111,10 +113,8 @@ def fchmod(fd: int, mode: int) -> None: ...
def fchown(fd: int, uid: int, gid: int) -> None: ...
def fdatasync(fd: int) -> None: ...
def fdopen(fd: int, mode: str = ..., bufsize: int = ...) -> IO[str]: ...
def fork() -> int:
raise OSError()
def forkpty() -> Tuple[int, int]:
raise OSError()
def fork() -> int: ...
def forkpty() -> Tuple[int, int]: ...
def fpathconf(fd: int, name: str) -> None: ...
def fstat(fd: int) -> stat_result: ...
def fstatvfs(fd: int) -> statvfs_result: ...
@@ -126,8 +126,7 @@ def getegid() -> int: ...
def geteuid() -> int: ...
def getgid() -> int: ...
def getgroups() -> List[int]: ...
def getloadavg() -> Tuple[float, float, float]:
raise OSError()
def getloadavg() -> Tuple[float, float, float]: ...
def getlogin() -> str: ...
def getpgid(pid: int) -> int: ...
def getpgrp() -> int: ...
@@ -143,8 +142,7 @@ def kill(pid: int, sig: int) -> None: ...
def killpg(pgid: int, sig: int) -> None: ...
def lchown(path: unicode, uid: int, gid: int) -> None: ...
def link(source: unicode, link_name: str) -> None: ...
_T = TypeVar("_T")
def listdir(path: _T) -> List[_T]: ...
def listdir(path: AnyStr) -> List[AnyStr]: ...
def lseek(fd: int, pos: int, how: int) -> None: ...
def lstat(path: unicode) -> stat_result: ...
def major(device: int) -> int: ...
@@ -194,12 +192,10 @@ def uname() -> Tuple[str, str, str, str, str]: ...
def unlink(path: unicode) -> None: ...
def unsetenv(varname: str) -> None: ...
def urandom(n: int) -> str: ...
def utime(path: unicode, times: Optional[Tuple[int, int]]) -> None:
raise OSError
def utime(path: unicode, times: Optional[Tuple[int, int]]) -> None: ...
def wait() -> int: ...
_r = Tuple[float, float, int, int, int, int, int, int, int, int, int, int, int, int, int, int]
def wait3(options: int) -> Tuple[int, int, _r]: ...
def wait4(pid: int, options: int) -> Tuple[int, int, _r]: ...
def waitpid(pid: int, options: int) -> int:
raise OSError()
def waitpid(pid: int, options: int) -> int: ...
def write(fd: int, str: str) -> int: ...
+9 -7
View File
@@ -7,12 +7,14 @@
# ----- random classes -----
import _random
from typing import (
Any, TypeVar, Sequence, List, Callable, AbstractSet, Union,
overload
)
from typing import AbstractSet, Any, Callable, Iterator, List, Protocol, Sequence, TypeVar, Union, overload
_T = TypeVar('_T')
_T = TypeVar("_T")
_T_co = TypeVar('_T_co', covariant=True)
class _Sampleable(Protocol[_T_co]):
def __iter__(self) -> Iterator[_T_co]: ...
def __len__(self) -> int: ...
class Random(_random.Random):
def __init__(self, x: object = ...) -> None: ...
@@ -28,7 +30,7 @@ class Random(_random.Random):
def randint(self, a: int, b: int) -> int: ...
def choice(self, seq: Sequence[_T]) -> _T: ...
def shuffle(self, x: List[Any], random: Callable[[], None] = ...) -> None: ...
def sample(self, population: Union[Sequence[_T], AbstractSet[_T]], k: int) -> List[_T]: ...
def sample(self, population: _Sampleable[_T], k: int) -> List[_T]: ...
def random(self) -> float: ...
def uniform(self, a: float, b: float) -> float: ...
def triangular(self, low: float = ..., high: float = ..., mode: float = ...) -> float: ...
@@ -59,7 +61,7 @@ def randrange(start: int, stop: int, step: int = ...) -> int: ...
def randint(a: int, b: int) -> int: ...
def choice(seq: Sequence[_T]) -> _T: ...
def shuffle(x: List[Any], random: Callable[[], float] = ...) -> None: ...
def sample(population: Union[Sequence[_T], AbstractSet[_T]], k: int) -> List[_T]: ...
def sample(population: _Sampleable[_T], k: int) -> List[_T]: ...
def random() -> float: ...
def uniform(a: float, b: float) -> float: ...
def triangular(low: float = ..., high: float = ...,
+15 -15
View File
@@ -10,21 +10,21 @@ from typing import (
)
# ----- re variables and constants -----
DEBUG = 0
I = 0
IGNORECASE = 0
L = 0
LOCALE = 0
M = 0
MULTILINE = 0
S = 0
DOTALL = 0
X = 0
VERBOSE = 0
U = 0
UNICODE = 0
T = 0
TEMPLATE = 0
DEBUG: int
I: int
IGNORECASE: int
L: int
LOCALE: int
M: int
MULTILINE: int
S: int
DOTALL: int
X: int
VERBOSE: int
U: int
UNICODE: int
T: int
TEMPLATE: int
class error(Exception): ...
+3 -1
View File
@@ -1,3 +1,5 @@
from typing import Any, List
class Repr:
maxarray: int
maxdeque: int
@@ -25,7 +27,7 @@ class Repr:
def repr_str(self, x, level: complex) -> str: ...
def repr_tuple(self, x, level: complex) -> str: ...
def _possibly_sorted(x) -> list: ...
def _possibly_sorted(x) -> List[Any]: ...
aRepr: Repr
def repr(x) -> str: ...
+18 -6
View File
@@ -19,12 +19,24 @@ RLIMIT_MEMLOCK: int
RLIMIT_VMEM: int
RLIMIT_AS: int
_RUsage = NamedTuple('_RUsage', [('ru_utime', float), ('ru_stime', float), ('ru_maxrss', int),
('ru_ixrss', int), ('ru_idrss', int), ('ru_isrss', int),
('ru_minflt', int), ('ru_majflt', int), ('ru_nswap', int),
('ru_inblock', int), ('ru_oublock', int), ('ru_msgsnd', int),
('ru_msgrcv', int), ('ru_nsignals', int), ('ru_nvcsw', int),
('ru_nivcsw', int)])
class _RUsage(NamedTuple):
ru_utime: float
ru_stime: float
ru_maxrss: int
ru_ixrss: int
ru_idrss: int
ru_isrss: int
ru_minflt: int
ru_majflt: int
ru_nswap: int
ru_inblock: int
ru_oublock: int
ru_msgsnd: int
ru_msgrcv: int
ru_nsignals: int
ru_nvcsw: int
ru_nivcsw: int
def getrusage(who: int) -> _RUsage: ...
def getpagesize() -> int: ...
+16 -16
View File
@@ -3,7 +3,7 @@ from typing import Any, Callable, Hashable, Iterable, Iterator, MutableMapping,
_T = TypeVar('_T')
_Setlike = Union[BaseSet[_T], Iterable[_T]]
_SelfT = TypeVar('_SelfT', bound=BaseSet)
_SelfT = TypeVar('_SelfT')
class BaseSet(Iterable[_T]):
def __init__(self) -> None: ...
@@ -18,13 +18,13 @@ class BaseSet(Iterable[_T]):
def __copy__(self: _SelfT) -> _SelfT: ...
def __deepcopy__(self: _SelfT, memo: MutableMapping[int, BaseSet[_T]]) -> _SelfT: ...
def __or__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ...
def union(self: _SelfT, other: _Setlike) -> _SelfT: ...
def union(self: _SelfT, other: _Setlike[_T]) -> _SelfT: ...
def __and__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ...
def intersection(self: _SelfT, other: _Setlike) -> _SelfT: ...
def intersection(self: _SelfT, other: _Setlike[Any]) -> _SelfT: ...
def __xor__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ...
def symmetric_difference(self: _SelfT, other: _Setlike) -> _SelfT: ...
def symmetric_difference(self: _SelfT, other: _Setlike[_T]) -> _SelfT: ...
def __sub__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ...
def difference(self: _SelfT, other: _Setlike) -> _SelfT: ...
def difference(self: _SelfT, other: _Setlike[Any]) -> _SelfT: ...
def __contains__(self, element: Any) -> bool: ...
def issubset(self, other: BaseSet[_T]) -> bool: ...
def issuperset(self, other: BaseSet[_T]) -> bool: ...
@@ -34,20 +34,20 @@ class BaseSet(Iterable[_T]):
def __gt__(self, other: BaseSet[_T]) -> bool: ...
class ImmutableSet(BaseSet[_T], Hashable):
def __init__(self, iterable: Optional[_Setlike] = ...) -> None: ...
def __init__(self, iterable: Optional[_Setlike[_T]] = ...) -> None: ...
def __hash__(self) -> int: ...
class Set(BaseSet[_T]):
def __init__(self, iterable: Optional[_Setlike] = ...) -> None: ...
def __ior__(self, other: BaseSet[_T]) -> Set: ...
def union_update(self, other: _Setlike) -> None: ...
def __iand__(self, other: BaseSet[_T]) -> Set: ...
def intersection_update(self, other: _Setlike) -> None: ...
def __ixor__(self, other: BaseSet[_T]) -> Set: ...
def symmetric_difference_update(self, other: _Setlike) -> None: ...
def __isub__(self, other: BaseSet[_T]) -> Set: ...
def difference_update(self, other: _Setlike) -> None: ...
def update(self, iterable: _Setlike) -> None: ...
def __init__(self, iterable: Optional[_Setlike[_T]] = ...) -> None: ...
def __ior__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ...
def union_update(self, other: _Setlike[_T]) -> None: ...
def __iand__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ...
def intersection_update(self, other: _Setlike[Any]) -> None: ...
def __ixor__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ...
def symmetric_difference_update(self, other: _Setlike[_T]) -> None: ...
def __isub__(self: _SelfT, other: BaseSet[_T]) -> _SelfT: ...
def difference_update(self, other: _Setlike[Any]) -> None: ...
def update(self, iterable: _Setlike[_T]) -> None: ...
def clear(self) -> None: ...
def add(self, element: _T) -> None: ...
def remove(self, element: _T) -> None: ...
+2 -2
View File
@@ -7,5 +7,5 @@ class sha(object):
def copy(self) -> sha: ...
def new(string: str = ...) -> sha: ...
blocksize = 0
digest_size = 0
blocksize: int
digest_size: int
+1 -1
View File
@@ -2,7 +2,7 @@ from typing import Any, Dict, Iterator, List, Optional, Tuple
import collections
class Shelf(collections.MutableMapping):
class Shelf(collections.MutableMapping[Any, Any]):
def __init__(self, dict: Dict[Any, Any], protocol: Optional[int] = ..., writeback: bool = ..., keyencoding: str = ...) -> None: ...
def __iter__(self) -> Iterator[str]: ...
def keys(self) -> List[Any]: ...
+1
View File
@@ -7,6 +7,7 @@ _SLT = TypeVar('_SLT', bound=shlex)
class shlex:
def __init__(self, instream: IO[Any] = ..., infile: IO[Any] = ..., posix: bool = ...) -> None: ...
def __iter__(self: _SLT) -> _SLT: ...
def next(self) -> str: ...
def get_token(self) -> Optional[str]: ...
def push_token(self, _str: str) -> None: ...
def read_token(self) -> str: ...
+3 -6
View File
@@ -63,9 +63,6 @@ def pause() -> None: ...
def setitimer(which: int, seconds: float, interval: float = ...) -> Tuple[float, float]: ...
def getitimer(which: int) -> Tuple[float, float]: ...
def set_wakeup_fd(fd: int) -> int: ...
def siginterrupt(signalnum: int, flag: bool) -> None:
raise RuntimeError()
def signal(signalnum: int, handler: _HANDLER) -> _HANDLER:
raise RuntimeError()
def default_int_handler(signum: int, frame: FrameType) -> None:
raise KeyboardInterrupt()
def siginterrupt(signalnum: int, flag: bool) -> None: ...
def signal(signalnum: int, handler: _HANDLER) -> _HANDLER: ...
def default_int_handler(signum: int, frame: FrameType) -> None: ...
+10 -9
View File
@@ -1,14 +1,15 @@
from typing import List, NamedTuple
struct_spwd = NamedTuple("struct_spwd", [("sp_nam", str),
("sp_pwd", str),
("sp_lstchg", int),
("sp_min", int),
("sp_max", int),
("sp_warn", int),
("sp_inact", int),
("sp_expire", int),
("sp_flag", int)])
class struct_spwd(NamedTuple):
sp_nam: str
sp_pwd: str
sp_lstchg: int
sp_min: int
sp_max: int
sp_warn: int
sp_inact: int
sp_expire: int
sp_flag: int
def getspall() -> List[struct_spwd]: ...
def getspnam(name: str) -> struct_spwd: ...
+6 -6
View File
@@ -4,10 +4,10 @@ from typing import Any, Dict, Iterable, List, Match, Optional, Pattern as _Patte
SPECIAL_CHARS: str
REPEAT_CHARS: str
DIGITS: Set
OCTDIGITS: Set
HEXDIGITS: Set
WHITESPACE: Set
DIGITS: Set[Any]
OCTDIGITS: Set[Any]
HEXDIGITS: Set[Any]
WHITESPACE: Set[Any]
ESCAPES: Dict[str, Tuple[str, int]]
CATEGORIES: Dict[str, Union[Tuple[str, str], Tuple[str, List[Tuple[str, str]]]]]
FLAGS: Dict[str, int]
@@ -59,5 +59,5 @@ def isdigit(char: str) -> bool: ...
def isname(name: str) -> bool: ...
def parse(str: str, flags: int = ..., pattern: Pattern = ...) -> SubPattern: ...
_Template = Tuple[List[Tuple[int, int]], List[Optional[int]]]
def parse_template(source: str, pattern: _Pattern) -> _Template: ...
def expand_template(template: _Template, match: Match) -> str: ...
def parse_template(source: str, pattern: _Pattern[Any]) -> _Template: ...
def expand_template(template: _Template, match: Match[Any]) -> str: ...
+48 -48
View File
@@ -9,51 +9,51 @@ def S_ISSOCK(mode: int) -> bool: ...
def S_IMODE(mode: int) -> int: ...
def S_IFMT(mode: int) -> int: ...
ST_MODE = 0
ST_INO = 0
ST_DEV = 0
ST_NLINK = 0
ST_UID = 0
ST_GID = 0
ST_SIZE = 0
ST_ATIME = 0
ST_MTIME = 0
ST_CTIME = 0
S_IFSOCK = 0
S_IFLNK = 0
S_IFREG = 0
S_IFBLK = 0
S_IFDIR = 0
S_IFCHR = 0
S_IFIFO = 0
S_ISUID = 0
S_ISGID = 0
S_ISVTX = 0
S_IRWXU = 0
S_IRUSR = 0
S_IWUSR = 0
S_IXUSR = 0
S_IRWXG = 0
S_IRGRP = 0
S_IWGRP = 0
S_IXGRP = 0
S_IRWXO = 0
S_IROTH = 0
S_IWOTH = 0
S_IXOTH = 0
S_ENFMT = 0
S_IREAD = 0
S_IWRITE = 0
S_IEXEC = 0
UF_NODUMP = 0
UF_IMMUTABLE = 0
UF_APPEND = 0
UF_OPAQUE = 0
UF_NOUNLINK = 0
UF_COMPRESSED = 0
UF_HIDDEN = 0
SF_ARCHIVED = 0
SF_IMMUTABLE = 0
SF_APPEND = 0
SF_NOUNLINK = 0
SF_SNAPSHOT = 0
ST_MODE: int
ST_INO: int
ST_DEV: int
ST_NLINK: int
ST_UID: int
ST_GID: int
ST_SIZE: int
ST_ATIME: int
ST_MTIME: int
ST_CTIME: int
S_IFSOCK: int
S_IFLNK: int
S_IFREG: int
S_IFBLK: int
S_IFDIR: int
S_IFCHR: int
S_IFIFO: int
S_ISUID: int
S_ISGID: int
S_ISVTX: int
S_IRWXU: int
S_IRUSR: int
S_IWUSR: int
S_IXUSR: int
S_IRWXG: int
S_IRGRP: int
S_IWGRP: int
S_IXGRP: int
S_IRWXO: int
S_IROTH: int
S_IWOTH: int
S_IXOTH: int
S_ENFMT: int
S_IREAD: int
S_IWRITE: int
S_IEXEC: int
UF_NODUMP: int
UF_IMMUTABLE: int
UF_APPEND: int
UF_OPAQUE: int
UF_NOUNLINK: int
UF_COMPRESSED: int
UF_HIDDEN: int
SF_ARCHIVED: int
SF_IMMUTABLE: int
SF_APPEND: int
SF_NOUNLINK: int
SF_SNAPSHOT: int
+1 -4
View File
@@ -68,10 +68,7 @@ class Formatter(object):
def parse(self, format_string: str) -> Iterable[Tuple[str, str, str, str]]: ...
def get_field(self, field_name: str, args: Sequence[Any],
kwargs: Mapping[str, Any]) -> Any: ...
def get_value(self, key: Union[int, str], args: Sequence[Any],
kwargs: Mapping[str, Any]) -> Any:
raise IndexError()
raise KeyError()
def get_value(self, key: Union[int, str], args: Sequence[Any], kwargs: Mapping[str, Any]) -> Any: ...
def check_unused_args(self, used_args: Sequence[Union[int, str]], args: Sequence[Any],
kwargs: Mapping[str, Any]) -> None: ...
def format_field(self, value: Any, format_spec: str) -> Any: ...
+20 -63
View File
@@ -6,67 +6,24 @@ lowercase: str
uppercase: str
whitespace: str
def atof(a: str) -> float:
raise DeprecationWarning()
def atoi(a: str, base: int = ...) -> int:
raise DeprecationWarning()
def atol(a: str, base: int = ...) -> long:
raise DeprecationWarning()
def capitalize(s: str) -> str:
raise DeprecationWarning()
def count(s: str, sub: str, start: int = ..., end: int = ...) -> int:
raise DeprecationWarning()
def expandtabs(string: str, tabsize: int = ...) -> str:
raise DeprecationWarning()
raise OverflowError()
def find(s: str, sub: str, start: int = ..., end: int = ...) -> int:
raise DeprecationWarning()
def join(list: Sequence[str], sep: str = ...) -> str:
raise DeprecationWarning()
raise OverflowError()
def joinfields(list: Sequence[str], sep: str = ...) -> str:
raise DeprecationWarning()
raise OverflowError()
def lower(s: str) -> str:
raise DeprecationWarning()
def lstrip(s: str) -> str:
raise DeprecationWarning()
def atof(a: str) -> float: ...
def atoi(a: str, base: int = ...) -> int: ...
def atol(a: str, base: int = ...) -> long: ...
def capitalize(s: str) -> str: ...
def count(s: str, sub: str, start: int = ..., end: int = ...) -> int: ...
def expandtabs(string: str, tabsize: int = ...) -> str: ...
def find(s: str, sub: str, start: int = ..., end: int = ...) -> int: ...
def join(list: Sequence[str], sep: str = ...) -> str: ...
def joinfields(list: Sequence[str], sep: str = ...) -> str: ...
def lower(s: str) -> str: ...
def lstrip(s: str) -> str: ...
def maketrans(frm: str, to: str) -> str: ...
def replace(s: str, old: str, new: str, maxsplit: int = ...) -> str:
raise DeprecationWarning()
def rfind(s: str, sub: str, start: int = ..., end: int = ...) -> int:
raise DeprecationWarning()
def rstrip(s: str) -> str:
raise DeprecationWarning()
def split(s: str, sep: str, maxsplit: int = ...) -> List[str]:
raise DeprecationWarning()
def splitfields(s: str, sep: str, maxsplit: int = ...) -> List[str]:
raise DeprecationWarning()
def strip(s: str) -> str:
raise DeprecationWarning()
def swapcase(s: str) -> str:
raise DeprecationWarning()
def translate(s: str, table: str, deletechars: str = ...) -> str:
raise DeprecationWarning()
def upper(s: str) -> str:
raise DeprecationWarning()
def replace(s: str, old: str, new: str, maxsplit: int = ...) -> str: ...
def rfind(s: str, sub: str, start: int = ..., end: int = ...) -> int: ...
def rstrip(s: str) -> str: ...
def split(s: str, sep: str, maxsplit: int = ...) -> List[str]: ...
def splitfields(s: str, sep: str, maxsplit: int = ...) -> List[str]: ...
def strip(s: str) -> str: ...
def swapcase(s: str) -> str: ...
def translate(s: str, table: str, deletechars: str = ...) -> str: ...
def upper(s: str) -> str: ...
+30 -27
View File
@@ -2,7 +2,9 @@
# Based on http://docs.python.org/2/library/subprocess.html and Python 3 stub
from typing import Sequence, Any, Mapping, Callable, Tuple, IO, Union, Optional, List, Text
from typing import (
Sequence, Any, Mapping, Callable, Tuple, IO, Union, Optional, List, Text, TypeVar, Generic,
)
_FILE = Union[None, int, IO[Any]]
_TXT = Union[bytes, Text]
@@ -59,49 +61,50 @@ PIPE: int
STDOUT: int
class CalledProcessError(Exception):
returncode = 0
returncode: int
# morally: _CMD
cmd: Any
# morally: Optional[bytes]
output: Any
output: bytes
def __init__(self,
returncode: int,
cmd: _CMD,
output: Optional[bytes] = ...) -> None: ...
class Popen:
stdin: Optional[IO[Any]]
stdout: Optional[IO[Any]]
stderr: Optional[IO[Any]]
pid = 0
returncode = 0
# We use a dummy type variable used to make Popen generic like it is in python 3
_T = TypeVar('_T', bound=bytes)
def __init__(self,
args: _CMD,
bufsize: int = ...,
executable: Optional[_TXT] = ...,
stdin: Optional[_FILE] = ...,
stdout: Optional[_FILE] = ...,
stderr: Optional[_FILE] = ...,
preexec_fn: Optional[Callable[[], Any]] = ...,
close_fds: bool = ...,
shell: bool = ...,
cwd: Optional[_TXT] = ...,
env: Optional[_ENV] = ...,
universal_newlines: bool = ...,
startupinfo: Optional[Any] = ...,
creationflags: int = ...) -> None: ...
class Popen(Generic[_T]):
stdin: Optional[IO[bytes]]
stdout: Optional[IO[bytes]]
stderr: Optional[IO[bytes]]
pid: int
returncode: int
def __new__(cls,
args: _CMD,
bufsize: int = ...,
executable: Optional[_TXT] = ...,
stdin: Optional[_FILE] = ...,
stdout: Optional[_FILE] = ...,
stderr: Optional[_FILE] = ...,
preexec_fn: Optional[Callable[[], Any]] = ...,
close_fds: bool = ...,
shell: bool = ...,
cwd: Optional[_TXT] = ...,
env: Optional[_ENV] = ...,
universal_newlines: bool = ...,
startupinfo: Optional[Any] = ...,
creationflags: int = ...) -> Popen[bytes]: ...
def poll(self) -> int: ...
def wait(self) -> int: ...
# morally: -> Tuple[Optional[bytes], Optional[bytes]]
def communicate(self, input: Optional[_TXT] = ...) -> Tuple[Any, Any]: ...
def communicate(self, input: Optional[_TXT] = ...) -> Tuple[bytes, bytes]: ...
def send_signal(self, signal: int) -> None: ...
def terminate(self) -> None: ...
def kill(self) -> None: ...
def __enter__(self) -> Popen: ...
def __exit__(self, type, value, traceback) -> bool: ...
def list2cmdline(seq: Sequence[str]) -> str: ... # undocumented
+7 -9
View File
@@ -8,7 +8,7 @@ from types import FrameType, ModuleType, TracebackType, ClassType
# The following type alias are stub-only and do not exist during runtime
_ExcInfo = Tuple[Type[BaseException], BaseException, TracebackType]
_OptExcInfo = Tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]]
_OptExcInfo = Union[_ExcInfo, Tuple[None, None, None]]
class _flags:
bytes_warning: int
@@ -42,11 +42,11 @@ class _float_info:
rounds: int
class _version_info(Tuple[int, int, int, str, int]):
major = 0
minor = 0
micro = 0
major: int
minor: int
micro: int
releaselevel: str
serial = 0
serial: int
_mercurial: Tuple[str, str, str]
api_version: int
@@ -114,13 +114,11 @@ def _getframe(depth: int = ...) -> FrameType: ...
def call_tracing(fn: Any, args: Any) -> Any: ...
def __displayhook__(value: int) -> None: ...
def __excepthook__(type_: type, value: BaseException, traceback: TracebackType) -> None: ...
def exc_clear() -> None:
raise DeprecationWarning()
def exc_clear() -> None: ...
def exc_info() -> _OptExcInfo: ...
# sys.exit() accepts an optional argument of anything printable
def exit(arg: Any = ...) -> NoReturn:
raise SystemExit()
def exit(arg: Any = ...) -> NoReturn: ...
def getcheckinterval() -> int: ... # deprecated
def getdefaultencoding() -> str: ...
def getdlopenflags() -> int: ...
+4 -4
View File
@@ -19,12 +19,12 @@ class _RandomNameSequence:
class _TemporaryFileWrapper(IO[str]):
delete: bool
file: IO
file: IO[str]
name: Any
def __init__(self, file: IO, name: Any, delete: bool = ...) -> None: ...
def __init__(self, file: IO[str], name: Any, delete: bool = ...) -> None: ...
def __del__(self) -> None: ...
def __enter__(self) -> _TemporaryFileWrapper: ...
def __exit__(self, exc, value, tb) -> bool: ...
def __exit__(self, exc, value, tb) -> Optional[bool]: ...
def __getattr__(self, name: unicode) -> Any: ...
def close(self) -> None: ...
def unlink(self, path: unicode) -> None: ...
@@ -88,7 +88,7 @@ class TemporaryDirectory:
dir: Union[bytes, unicode] = ...) -> None: ...
def cleanup(self) -> None: ...
def __enter__(self) -> Any: ... # Can be str or unicode
def __exit__(self, type, value, traceback) -> bool: ...
def __exit__(self, type, value, traceback) -> None: ...
@overload
def mkstemp() -> Tuple[int, str]: ...
+2 -4
View File
@@ -21,10 +21,8 @@ class _localdummy(object): ...
def start_new(function: Callable[..., Any], args: Any, kwargs: Any = ...) -> int: ...
def start_new_thread(function: Callable[..., Any], args: Any, kwargs: Any = ...) -> int: ...
def interrupt_main() -> None: ...
def exit() -> None:
raise SystemExit()
def exit_thread() -> Any:
raise SystemExit()
def exit() -> None: ...
def exit_thread() -> Any: ...
def allocate_lock() -> LockType: ...
def get_ident() -> int: ...
def stack_size(size: int = ...) -> int: ...
-2
View File
@@ -4,8 +4,6 @@
from pipes import Template
from typing import Dict, List
__all__: List[str]
table: Dict[str, Template]
t: Template
uncompress: Template
+19 -2
View File
@@ -64,6 +64,23 @@ class CodeType:
co_nlocals: int
co_stacksize: int
co_varnames: Tuple[str, ...]
def __init__(
self,
argcount: int,
nlocals: int,
stacksize: int,
flags: int,
codestring: str,
constants: Tuple[Any, ...],
names: Tuple[str, ...],
varnames: Tuple[str, ...],
filename: str,
name: str,
firstlineno: int,
lnotab: str,
freevars: Tuple[str, ...] = ...,
cellvars: Tuple[str, ...] = ...,
) -> None: ...
class GeneratorType:
gi_code: CodeType
@@ -86,7 +103,7 @@ class UnboundMethodType:
__name__: str
__func__ = im_func
__self__ = im_self
def __init__(self, func: Callable, obj: object) -> None: ...
def __init__(self, func: Callable[..., Any], obj: object) -> None: ...
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
class InstanceType(object): ...
@@ -137,7 +154,7 @@ class EllipsisType: ...
class DictProxyType:
# TODO is it possible to have non-string keys?
# no __init__
def copy(self) -> dict: ...
def copy(self) -> Dict[Any, Any]: ...
def get(self, key: str, default: _T = ...) -> Union[Any, _T]: ...
def has_key(self, key: str) -> bool: ...
def items(self) -> List[Tuple[str, Any]]: ...
+59 -33
View File
@@ -11,7 +11,6 @@ overload = object()
Any = object()
TypeVar = object()
_promote = object()
no_type_check = object()
class _SpecialForm(object):
def __getitem__(self, typeargs: Any) -> object: ...
@@ -22,6 +21,12 @@ Protocol: _SpecialForm = ...
Callable: _SpecialForm = ...
Type: _SpecialForm = ...
ClassVar: _SpecialForm = ...
Final: _SpecialForm = ...
_F = TypeVar('_F', bound=Callable[..., Any])
def final(f: _F) -> _F: ...
Literal: _SpecialForm = ...
# TypedDict is a (non-subscriptable) special form.
TypedDict: object = ...
class GenericMeta(type): ...
@@ -30,6 +35,22 @@ class GenericMeta(type): ...
# distinguish the None type from the None value.
NoReturn = Union[None]
# These type variables are used by the container types.
_T = TypeVar('_T')
_S = TypeVar('_S')
_KT = TypeVar('_KT') # Key type.
_VT = TypeVar('_VT') # Value type.
_T_co = TypeVar('_T_co', covariant=True) # Any type covariant containers.
_V_co = TypeVar('_V_co', covariant=True) # Any type covariant containers.
_KT_co = TypeVar('_KT_co', covariant=True) # Key type covariant containers.
_VT_co = TypeVar('_VT_co', covariant=True) # Value type covariant containers.
_T_contra = TypeVar('_T_contra', contravariant=True) # Ditto contravariant.
_TC = TypeVar('_TC', bound=Type[object])
_C = TypeVar("_C", bound=Callable[..., Any])
no_type_check = object()
def no_type_check_decorator(decorator: _C) -> _C: ...
# Type aliases and type constructors
class TypeAlias:
@@ -52,52 +73,39 @@ AnyStr = TypeVar('AnyStr', str, unicode)
# Abstract base classes.
# These type variables are used by the container types.
_T = TypeVar('_T')
_S = TypeVar('_S')
_KT = TypeVar('_KT') # Key type.
_VT = TypeVar('_VT') # Value type.
_T_co = TypeVar('_T_co', covariant=True) # Any type covariant containers.
_V_co = TypeVar('_V_co', covariant=True) # Any type covariant containers.
_KT_co = TypeVar('_KT_co', covariant=True) # Key type covariant containers.
_VT_co = TypeVar('_VT_co', covariant=True) # Value type covariant containers.
_T_contra = TypeVar('_T_contra', contravariant=True) # Ditto contravariant.
_TC = TypeVar('_TC', bound=Type[object])
_C = TypeVar("_C", bound=Callable)
def runtime_checkable(cls: _TC) -> _TC: ...
def runtime(cls: _TC) -> _TC: ...
@runtime
@runtime_checkable
class SupportsInt(Protocol, metaclass=ABCMeta):
@abstractmethod
def __int__(self) -> int: ...
@runtime
@runtime_checkable
class SupportsFloat(Protocol, metaclass=ABCMeta):
@abstractmethod
def __float__(self) -> float: ...
@runtime
@runtime_checkable
class SupportsComplex(Protocol, metaclass=ABCMeta):
@abstractmethod
def __complex__(self) -> complex: ...
@runtime
@runtime_checkable
class SupportsAbs(Protocol[_T_co]):
@abstractmethod
def __abs__(self) -> _T_co: ...
@runtime
@runtime_checkable
class Reversible(Protocol[_T_co]):
@abstractmethod
def __reversed__(self) -> Iterator[_T_co]: ...
@runtime
@runtime_checkable
class Sized(Protocol, metaclass=ABCMeta):
@abstractmethod
def __len__(self) -> int: ...
@runtime
@runtime_checkable
class Hashable(Protocol, metaclass=ABCMeta):
# TODO: This is special, in that a subclass of a hashable class may not be hashable
# (for example, list vs. object). It's not obvious how to represent this. This class
@@ -105,12 +113,12 @@ class Hashable(Protocol, metaclass=ABCMeta):
@abstractmethod
def __hash__(self) -> int: ...
@runtime
@runtime_checkable
class Iterable(Protocol[_T_co]):
@abstractmethod
def __iter__(self) -> Iterator[_T_co]: ...
@runtime
@runtime_checkable
class Iterator(Iterable[_T_co], Protocol[_T_co]):
@abstractmethod
def next(self) -> _T_co: ...
@@ -135,7 +143,7 @@ class Generator(Iterator[_T_co], Generic[_T_co, _T_contra, _V_co]):
@property
def gi_running(self) -> bool: ...
@runtime
@runtime_checkable
class Container(Protocol[_T_co]):
@abstractmethod
def __contains__(self, x: object) -> bool: ...
@@ -234,7 +242,7 @@ class ValuesView(MappingView, Iterable[_VT_co], Generic[_VT_co]):
def __contains__(self, o: object) -> bool: ...
def __iter__(self) -> Iterator[_VT_co]: ...
@runtime
@runtime_checkable
class ContextManager(Protocol[_T_co]):
def __enter__(self) -> _T_co: ...
def __exit__(self, __exc_type: Optional[Type[BaseException]],
@@ -337,7 +345,7 @@ class IO(Iterator[AnyStr], Generic[AnyStr]):
def __enter__(self) -> IO[AnyStr]: ...
@abstractmethod
def __exit__(self, t: Optional[Type[BaseException]], value: Optional[BaseException],
traceback: Optional[TracebackType]) -> bool: ...
traceback: Optional[TracebackType]) -> Optional[bool]: ...
class BinaryIO(IO[str]):
# TODO readinto
@@ -398,6 +406,8 @@ class Match(Generic[AnyStr]):
def start(self, group: Union[int, str] = ...) -> int: ...
def end(self, group: Union[int, str] = ...) -> int: ...
def span(self, group: Union[int, str] = ...) -> Tuple[int, int]: ...
@property
def regs(self) -> Tuple[Tuple[int, int], ...]: ... # undocumented
# We need a second TypeVar with the same definition as AnyStr, because
# Pattern is generic over AnyStr (determining the type of its .pattern
@@ -439,8 +449,9 @@ class Pattern(Generic[AnyStr]):
# Functions
def get_type_hints(obj: Callable, globalns: Optional[dict[Text, Any]] = ...,
localns: Optional[dict[Text, Any]] = ...) -> None: ...
def get_type_hints(
obj: Callable[..., Any], globalns: Optional[Dict[Text, Any]] = ..., localns: Optional[Dict[Text, Any]] = ...,
) -> None: ...
@overload
def cast(tp: Type[_T], obj: Any) -> _T: ...
@@ -450,18 +461,33 @@ def cast(tp: str, obj: Any) -> Any: ...
# Type constructors
# NamedTuple is special-cased in the type checker
class NamedTuple(tuple):
class NamedTuple(Tuple[Any, ...]):
_fields: Tuple[str, ...]
def __init__(self, typename: Text, fields: Iterable[Tuple[Text, Any]] = ..., *,
verbose: bool = ..., rename: bool = ..., **kwargs: Any) -> None: ...
def __init__(self, typename: Text, fields: Iterable[Tuple[Text, Any]] = ...,
**kwargs: Any) -> None: ...
@classmethod
def _make(cls: Type[_T], iterable: Iterable[Any]) -> _T: ...
def _asdict(self) -> dict: ...
def _asdict(self) -> Dict[str, Any]: ...
def _replace(self: _T, **kwargs: Any) -> _T: ...
# Internal mypy fallback type for all typed dicts (does not exist at runtime)
class _TypedDict(Mapping[str, object], metaclass=ABCMeta):
def copy(self: _T) -> _T: ...
# Using NoReturn so that only calls using mypy plugin hook that specialize the signature
# can go through.
def setdefault(self, k: NoReturn, default: object) -> object: ...
# Mypy plugin hook for 'pop' expects that 'default' has a type variable type.
def pop(self, k: NoReturn, default: _T = ...) -> object: ...
def update(self: _T, __m: _T) -> None: ...
def has_key(self, k: str) -> bool: ...
def viewitems(self) -> ItemsView[str, object]: ...
def viewkeys(self) -> KeysView[str]: ...
def viewvalues(self) -> ValuesView[object]: ...
def __delitem__(self, k: NoReturn) -> None: ...
def NewType(name: str, tp: Type[_T]) -> Type[_T]: ...
# This itself is only available during type checking
+23 -3
View File
@@ -3,9 +3,10 @@
# Based on http://docs.python.org/2.7/library/unittest.html
from typing import (Any, Callable, Dict, FrozenSet, Iterable, Iterator,
List, NoReturn, Optional, overload, Pattern, Sequence, Set,
Text, TextIO, Tuple, Type, TypeVar, Union)
List, Mapping, NoReturn, Optional, overload, Pattern,
Sequence, Set, Text, TextIO, Tuple, Type, TypeVar, Union)
from abc import abstractmethod, ABCMeta
import datetime
import types
_T = TypeVar('_T')
@@ -96,11 +97,19 @@ class TestCase(Testable):
def assertAlmostEqual(self, first: float, second: float, *,
msg: Any = ..., delta: float = ...) -> None: ...
@overload
def assertAlmostEqual(self, first: datetime.datetime,
second: datetime.datetime, *,
msg: Any = ..., delta: datetime.timedelta = ...) -> None: ...
@overload
def assertAlmostEquals(self, first: float, second: float,
places: int = ..., msg: Any = ...) -> None: ...
@overload
def assertAlmostEquals(self, first: float, second: float, *,
msg: Any = ..., delta: float = ...) -> None: ...
@overload
def assertAlmostEquals(self, first: datetime.datetime,
second: datetime.datetime, *,
msg: Any = ..., delta: datetime.timedelta = ...) -> None: ...
def failUnlessAlmostEqual(self, first: float, second: float, places: int = ...,
msg: object = ...) -> None: ...
@overload
@@ -110,11 +119,19 @@ class TestCase(Testable):
def assertNotAlmostEqual(self, first: float, second: float, *,
msg: Any = ..., delta: float = ...) -> None: ...
@overload
def assertNotAlmostEqual(self, first: datetime.datetime,
second: datetime.datetime, *,
msg: Any = ..., delta: datetime.timedelta = ...) -> None: ...
@overload
def assertNotAlmostEquals(self, first: float, second: float,
places: int = ..., msg: Any = ...) -> None: ...
@overload
def assertNotAlmostEquals(self, first: float, second: float, *,
msg: Any = ..., delta: float = ...) -> None: ...
@overload
def assertNotAlmostEquals(self, first: datetime.datetime,
second: datetime.datetime, *,
msg: Any = ..., delta: datetime.timedelta = ...) -> None: ...
def failIfAlmostEqual(self, first: float, second: float, places: int = ...,
msg: object = ...,
delta: float = ...) -> None: ...
@@ -149,7 +166,10 @@ class TestCase(Testable):
def assertRegexpMatches(self, text: Text, regexp: _Regexp, msg: object = ...) -> None: ...
def assertNotRegexpMatches(self, text: Text, regexp: _Regexp, msg: object = ...) -> None: ...
def assertItemsEqual(self, first: Iterable[Any], second: Iterable[Any], msg: object = ...) -> None: ...
def assertDictContainsSubset(self, expected: Dict[Any, Any], actual: Dict[Any, Any], msg: object = ...) -> None: ...
def assertDictContainsSubset(self,
expected: Mapping[Any, Any],
actual: Mapping[Any, Any],
msg: object = ...) -> None: ...
def addTypeEqualityFunc(self, typeobj: type, function: Callable[..., None]) -> None: ...
@overload
def failUnlessRaises(self, exception: _ExceptionType, callable: Callable[..., Any], *args: Any, **kwargs: Any) -> None: ...
+1 -1
View File
@@ -128,7 +128,7 @@ def quote_plus(s: AnyStr, safe: Text = ...) -> AnyStr: ...
def urlencode(query: Union[Sequence[Tuple[Any, Any]], Mapping[Any, Any]], doseq=...) -> str: ...
def getproxies() -> Mapping[str, str]: ...
def proxy_bypass(host): ...
def proxy_bypass(host: str) -> Any: ... # Undocumented
# Names in __all__ with no definition:
# basejoin
+21 -25
View File
@@ -1,6 +1,6 @@
# Stubs for urlparse (Python 2)
from typing import AnyStr, Dict, List, NamedTuple, Tuple, Sequence, Union, overload
from typing import AnyStr, Dict, List, NamedTuple, Tuple, Sequence, Union, overload, Optional
_String = Union[str, unicode]
@@ -11,41 +11,37 @@ non_hierarchical: List[str]
uses_query: List[str]
uses_fragment: List[str]
scheme_chars: str
MAX_CACHE_SIZE = 0
MAX_CACHE_SIZE: int
def clear_cache() -> None: ...
class ResultMixin(object):
@property
def username(self) -> str: ...
def username(self) -> Optional[str]: ...
@property
def password(self) -> str: ...
def password(self) -> Optional[str]: ...
@property
def hostname(self) -> str: ...
def hostname(self) -> Optional[str]: ...
@property
def port(self) -> int: ...
def port(self) -> Optional[int]: ...
class SplitResult(
NamedTuple(
'SplitResult',
[
('scheme', str), ('netloc', str), ('path', str), ('query', str), ('fragment', str)
]
),
ResultMixin
):
class _SplitResult(NamedTuple):
scheme: str
netloc: str
path: str
query: str
fragment: str
class SplitResult(_SplitResult, ResultMixin):
def geturl(self) -> str: ...
class ParseResult(
NamedTuple(
'ParseResult',
[
('scheme', str), ('netloc', str), ('path', str), ('params', str), ('query', str),
('fragment', str)
]
),
ResultMixin
):
class _ParseResult(NamedTuple):
scheme: str
netloc: str
path: str
params: str
query: str
fragment: str
class ParseResult(_ParseResult, ResultMixin):
def geturl(self) -> str: ...
def urlparse(url: _String, scheme: _String = ...,
+52 -20
View File
@@ -12,7 +12,7 @@ from gzip import GzipFile
_Unmarshaller = Any
_timeTuple = Tuple[int, int, int, int, int, int, int, int, int]
# Represents types that can be compared against a DateTime object
_dateTimeComp = Union[AnyStr, DateTime, datetime, _timeTuple]
_dateTimeComp = Union[unicode, DateTime, datetime]
# A "host description" used by Transport factories
_hostDesc = Union[str, Tuple[str, Mapping[Any, Any]]]
@@ -55,26 +55,26 @@ Boolean: Type[bool]
class DateTime:
value: str
def __init__(self, value: Union[str, unicode, datetime, float, int, _timeTuple, struct_time] = ...) -> None: ...
def make_comparable(self, other: _dateTimeComp) -> Tuple[_dateTimeComp, _dateTimeComp]: ...
def make_comparable(self, other: _dateTimeComp) -> Tuple[unicode, unicode]: ...
def __lt__(self, other: _dateTimeComp) -> bool: ...
def __le__(self, other: _dateTimeComp) -> bool: ...
def __gt__(self, other: _dateTimeComp) -> bool: ...
def __ge__(self, other: _dateTimeComp) -> bool: ...
def __eq__(self, other: _dateTimeComp) -> bool: ...
def __ne__(self, other: _dateTimeComp) -> bool: ...
def __eq__(self, other: _dateTimeComp) -> bool: ... # type: ignore
def __ne__(self, other: _dateTimeComp) -> bool: ... # type: ignore
def timetuple(self) -> struct_time: ...
def __cmp__(self, other: _dateTimeComp) -> int: ...
def decode(self, data: Any) -> None: ...
def encode(self, out: IO) -> None: ...
def encode(self, out: IO[str]) -> None: ...
class Binary:
data: str
def __init__(self, data: Optional[str] = ...) -> None: ...
def __cmp__(self, other: Any) -> int: ...
def decode(self, data: str) -> None: ...
def encode(self, out: IO) -> None: ...
def encode(self, out: IO[str]) -> None: ...
WRAPPERS: tuple
WRAPPERS: Tuple[Type[Any], ...]
# Still part of the public API, but see http://bugs.python.org/issue1773632
FastParser: None
@@ -104,7 +104,28 @@ class Marshaller:
allow_none: bool
def __init__(self, encoding: Optional[str] = ..., allow_none: bool = ...) -> None: ...
dispatch: Mapping[type, Callable[[Marshaller, str, Callable[[str], None]], None]]
def dumps(self, values: Union[Iterable[Union[None, int, bool, long, float, str, unicode, List, Tuple, Mapping, datetime, InstanceType]], Fault]) -> str: ...
def dumps(
self,
values: Union[
Iterable[
Union[
None,
int,
bool,
long,
float,
str,
unicode,
List[Any],
Tuple[Any, ...],
Mapping[Any, Any],
datetime,
InstanceType,
],
],
Fault,
],
) -> str: ...
def dump_nil(self, value: None, write: Callable[[str], None]) -> None: ...
def dump_int(self, value: int, write: Callable[[str], None]) -> None: ...
def dump_bool(self, value: bool, write: Callable[[str], None]) -> None: ...
@@ -112,15 +133,20 @@ class Marshaller:
def dump_double(self, value: float, write: Callable[[str], None]) -> None: ...
def dump_string(self, value: str, write: Callable[[str], None], escape: Callable[[AnyStr, Callable[[AnyStr, AnyStr, AnyStr], AnyStr]], AnyStr] = ...) -> None: ...
def dump_unicode(self, value: unicode, write: Callable[[str], None], escape: Callable[[AnyStr, Callable[[AnyStr, AnyStr, AnyStr], AnyStr]], AnyStr] = ...) -> None: ...
def dump_array(self, value: Union[List, Tuple], write: Callable[[str], None]) -> None: ...
def dump_struct(self, value: Mapping, write: Callable[[str], None], escape: Callable[[AnyStr, Callable[[AnyStr, AnyStr, AnyStr], AnyStr]], AnyStr] = ...) -> None: ...
def dump_array(self, value: Iterable[Any], write: Callable[[str], None]) -> None: ...
def dump_struct(
self,
value: Mapping[unicode, Any],
write: Callable[[str], None],
escape: Callable[[AnyStr, Callable[[AnyStr, AnyStr, AnyStr], AnyStr]], AnyStr] = ...,
) -> None: ...
def dump_datetime(self, value: datetime, write: Callable[[str], None]) -> None: ...
def dump_instance(self, value: InstanceType, write: Callable[[str], None]) -> None: ...
class Unmarshaller:
def append(self, object: Any) -> None: ...
def __init__(self, use_datetime: bool = ...) -> None: ...
def close(self) -> tuple: ...
def close(self) -> Tuple[Any, ...]: ...
def getmethodname(self) -> Optional[str]: ...
def xml(self, encoding: str, standalone: bool) -> None: ...
def start(self, tag: str, attrs: Any) -> None: ...
@@ -143,9 +169,9 @@ class Unmarshaller:
def end_methodName(self, data: str) -> None: ...
class _MultiCallMethod:
def __init__(self, call_list: List[Tuple[str, tuple]], name: str) -> None: ...
def __init__(self, call_list: List[Tuple[str, Tuple[Any, ...]]], name: str) -> None: ...
class MultiCallIterator:
def __init__(self, results: List) -> None: ...
def __init__(self, results: List[Any]) -> None: ...
class MultiCall:
def __init__(self, server: ServerProxy) -> None: ...
@@ -153,19 +179,25 @@ class MultiCall:
def __call__(self) -> MultiCallIterator: ...
def getparser(use_datetime: bool = ...) -> Tuple[Union[ExpatParser, SlowParser], Unmarshaller]: ...
def dumps(params: Union[tuple, Fault], methodname: Optional[str] = ..., methodresponse: Optional[bool] = ..., encoding: Optional[str] = ..., allow_none: bool = ...) -> str: ...
def loads(data: str, use_datetime: bool = ...) -> Tuple[tuple, Optional[str]]: ...
def dumps(
params: Union[Tuple[Any, ...], Fault],
methodname: Optional[str] = ...,
methodresponse: Optional[bool] = ...,
encoding: Optional[str] = ...,
allow_none: bool = ...,
) -> str: ...
def loads(data: str, use_datetime: bool = ...) -> Tuple[Tuple[Any, ...], Optional[str]]: ...
def gzip_encode(data: str) -> str: ...
def gzip_decode(data: str, max_decode: int = ...) -> str: ...
class GzipDecodedResponse(GzipFile):
stringio: StringIO
stringio: StringIO[Any]
def __init__(self, response: HTTPResponse) -> None: ...
def close(self): ...
class _Method:
def __init__(self, send: Callable[[str, tuple], Any], name: str) -> None: ...
def __init__(self, send: Callable[[str, Tuple[Any, ...]], Any], name: str) -> None: ...
def __getattr__(self, name: str) -> _Method: ...
def __call__(self, *args: Any) -> Any: ...
@@ -174,9 +206,9 @@ class Transport:
accept_gzip_encoding: bool
encode_threshold: Optional[int]
def __init__(self, use_datetime: bool = ...) -> None: ...
def request(self, host: _hostDesc, handler: str, request_body: str, verbose: bool = ...) -> tuple: ...
def request(self, host: _hostDesc, handler: str, request_body: str, verbose: bool = ...) -> Tuple[Any, ...]: ...
verbose: bool
def single_request(self, host: _hostDesc, handler: str, request_body: str, verbose: bool = ...) -> tuple: ...
def single_request(self, host: _hostDesc, handler: str, request_body: str, verbose: bool = ...) -> Tuple[Any, ...]: ...
def getparser(self) -> Tuple[Union[ExpatParser, SlowParser], Unmarshaller]: ...
def get_host_info(self, host: _hostDesc) -> Tuple[str, Optional[List[Tuple[str, str]]], Optional[Mapping[Any, Any]]]: ...
def make_connection(self, host: _hostDesc) -> HTTPConnection: ...
@@ -185,7 +217,7 @@ class Transport:
def send_host(self, connection: HTTPConnection, host: str) -> None: ...
def send_user_agent(self, connection: HTTPConnection) -> None: ...
def send_content(self, connection: HTTPConnection, request_body: str) -> None: ...
def parse_response(self, response: HTTPResponse) -> tuple: ...
def parse_response(self, response: HTTPResponse) -> Tuple[Any, ...]: ...
class SafeTransport(Transport):
def __init__(self, use_datetime: bool = ..., context: Optional[SSLContext] = ...) -> None: ...
+2 -1
View File
@@ -4,6 +4,7 @@ from typing import List
class _Feature:
def getOptionalRelease(self) -> sys._version_info: ...
def getMandatoryRelease(self) -> sys._version_info: ...
compiler_flag: int
absolute_import: _Feature
division: _Feature
@@ -21,4 +22,4 @@ if sys.version_info >= (3, 5):
if sys.version_info >= (3, 7):
annotations: _Feature
all_feature_names: List[str]
all_feature_names: List[str] # undocumented
+4 -4
View File
@@ -1,11 +1,11 @@
"""Stub file for the '_bisect' module."""
from typing import Sequence, TypeVar
from typing import Sequence, MutableSequence, TypeVar
_T = TypeVar('_T')
def bisect(a: Sequence[_T], x: _T, lo: int = ..., hi: int = ...) -> int: ...
def bisect_left(a: Sequence[_T], x: _T, lo: int = ..., hi: int = ...) -> int: ...
def bisect_right(a: Sequence[_T], x: _T, lo: int = ..., hi: int = ...) -> int: ...
def insort(a: Sequence[_T], x: _T, lo: int = ..., hi: int = ...) -> None: ...
def insort_left(a: Sequence[_T], x: _T, lo: int = ..., hi: int = ...) -> None: ...
def insort_right(a: Sequence[_T], x: _T, lo: int = ..., hi: int = ...) -> None: ...
def insort(a: MutableSequence[_T], x: _T, lo: int = ..., hi: int = ...) -> None: ...
def insort_left(a: MutableSequence[_T], x: _T, lo: int = ..., hi: int = ...) -> None: ...
def insort_right(a: MutableSequence[_T], x: _T, lo: int = ..., hi: int = ...) -> None: ...
+3 -2
View File
@@ -43,8 +43,9 @@ def raw_unicode_escape_encode(data: _Encodable, errors: _Errors = ...) -> Tuple[
def readbuffer_encode(data: _String, errors: _Errors = ...) -> Tuple[bytes, int]: ...
def unicode_escape_decode(data: _String, errors: _Errors = ...) -> Tuple[Text, int]: ...
def unicode_escape_encode(data: _Encodable, errors: _Errors = ...) -> Tuple[bytes, int]: ...
def unicode_internal_decode(data: _String, errors: _Errors = ...) -> Tuple[Text, int]: ...
def unicode_internal_encode(data: _String, errors: _Errors = ...) -> Tuple[bytes, int]: ...
if sys.version_info < (3, 8):
def unicode_internal_decode(data: _String, errors: _Errors = ...) -> Tuple[Text, int]: ...
def unicode_internal_encode(data: _String, errors: _Errors = ...) -> Tuple[bytes, int]: ...
def utf_16_be_decode(data: _Decodable, errors: _Errors = ..., final: int = ...) -> Tuple[Text, int]: ...
def utf_16_be_encode(data: _Encodable, errors: _Errors = ...) -> Tuple[bytes, int]: ...
def utf_16_decode(data: _Decodable, errors: _Errors = ..., final: int = ...) -> Tuple[Text, int]: ...
@@ -1,4 +1,5 @@
from typing import Any, BinaryIO, IO, Optional, Tuple, Union, overload
import sys
from typing import Any, BinaryIO, IO, NamedTuple, Optional, Tuple, Union, overload
_chtype = Union[str, bytes, int]
@@ -12,6 +13,8 @@ A_COLOR: int
A_DIM: int
A_HORIZONTAL: int
A_INVIS: int
if sys.version_info >= (3, 7):
A_ITALIC: int
A_LEFT: int
A_LOW: int
A_NORMAL: int
@@ -283,17 +286,20 @@ def tigetstr(capname: str) -> bytes: ...
def tparm(fmt: bytes, i1: int = ..., i2: int = ..., i3: int = ..., i4: int = ..., i5: int = ..., i6: int = ..., i7: int = ..., i8: int = ..., i9: int = ...) -> bytes: ...
def typeahead(fd: int) -> None: ...
def unctrl(ch: _chtype) -> bytes: ...
def unget_wch(ch: _chtype) -> None: ...
if sys.version_info >= (3, 3):
def unget_wch(ch: Union[int, str]) -> None: ...
def ungetch(ch: _chtype) -> None: ...
def ungetmouse(id: int, x: int, y: int, z: int, bstate: int) -> None: ...
def update_lines_cols() -> int: ...
if sys.version_info >= (3, 5):
def update_lines_cols() -> int: ...
def use_default_colors() -> None: ...
def use_env(flag: bool) -> None: ...
class error(Exception): ...
class _CursesWindow:
encoding: str
if sys.version_info >= (3, 3):
encoding: str
@overload
def addch(self, ch: _chtype, attr: int = ...) -> None: ...
@overload
@@ -344,13 +350,14 @@ class _CursesWindow:
def getbegyx(self) -> Tuple[int, int]: ...
def getbkgd(self) -> Tuple[int, int]: ...
@overload
def getch(self) -> _chtype: ...
def getch(self) -> int: ...
@overload
def getch(self, y: int, x: int) -> _chtype: ...
@overload
def get_wch(self) -> _chtype: ...
@overload
def get_wch(self, y: int, x: int) -> _chtype: ...
def getch(self, y: int, x: int) -> int: ...
if sys.version_info >= (3, 3):
@overload
def get_wch(self) -> Union[int, str]: ...
@overload
def get_wch(self, y: int, x: int) -> Union[int, str]: ...
@overload
def getkey(self) -> str: ...
@overload
@@ -445,3 +452,10 @@ class _CursesWindow:
def vline(self, ch: _chtype, n: int) -> None: ...
@overload
def vline(self, y: int, x: int, ch: _chtype, n: int) -> None: ...
if sys.version_info >= (3, 8):
class _ncurses_version(NamedTuple):
major: int
minor: int
patch: int
ncurses_version: _ncurses_version
+7 -7
View File
@@ -1,15 +1,15 @@
"""Stub file for the '_heapq' module."""
from typing import TypeVar, List
from typing import TypeVar, List, Iterable, Any, Callable, Optional
import sys
_T = TypeVar("_T")
def heapify(heap: List[_T]) -> None: ...
def heappop(heap: List[_T]) -> _T:
raise IndexError() # if list is empty
def heappop(heap: List[_T]) -> _T: ...
def heappush(heap: List[_T], item: _T) -> None: ...
def heappushpop(heap: List[_T], item: _T) -> _T: ...
def heapreplace(heap: List[_T], item: _T) -> _T:
raise IndexError() # if list is empty
def nlargest(a: int, b: List[_T]) -> List[_T]: ...
def nsmallest(a: int, b: List[_T]) -> List[_T]: ...
def heapreplace(heap: List[_T], item: _T) -> _T: ...
if sys.version_info < (3,):
def nlargest(n: int, iterable: Iterable[_T]) -> List[_T]: ...
def nsmallest(n: int, iterable: Iterable[_T]) -> List[_T]: ...
+34
View File
@@ -0,0 +1,34 @@
import sys
from typing import Any, Dict, List, Optional, Tuple, Type, Union, overload
if sys.version_info >= (3, 0):
_defaultaction: str
_onceregistry: Dict[Any, Any]
else:
default_action: str
once_registry: Dict[Any, Any]
filters: List[Tuple[Any, ...]]
@overload
def warn(message: str, category: Optional[Type[Warning]] = ..., stacklevel: int = ...) -> None: ...
@overload
def warn(message: Warning, category: Any = ..., stacklevel: int = ...) -> None: ...
@overload
def warn_explicit(
message: str,
category: Type[Warning],
filename: str,
lineno: int,
module: Optional[str] = ...,
registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ...,
module_globals: Optional[Dict[str, Any]] = ...,
) -> None: ...
@overload
def warn_explicit(
message: Warning,
category: Any,
filename: str,
lineno: int,
module: Optional[str] = ...,
registry: Optional[Dict[Union[str, Tuple[str, Type[Warning], int]], int]] = ...,
module_globals: Optional[Dict[str, Any]] = ...,
) -> None: ...
+1 -1
View File
@@ -2,7 +2,7 @@ from typing import Iterator, Any, Iterable, MutableSet, Optional, TypeVar, Gener
_S = TypeVar('_S')
_T = TypeVar('_T')
_SelfT = TypeVar('_SelfT', bound=WeakSet)
_SelfT = TypeVar('_SelfT', bound=WeakSet[Any])
class WeakSet(MutableSet[_T], Generic[_T]):
def __init__(self, data: Optional[Iterable[_T]] = ...) -> None: ...
+85
View File
@@ -0,0 +1,85 @@
from typing import Union, IO, Optional, Type, NamedTuple, List, Tuple, Any, Text, overload
from typing_extensions import Literal
from types import TracebackType
import sys
class Error(Exception): ...
class _aifc_params(NamedTuple):
nchannels: int
sampwidth: int
framerate: int
nframes: int
comptype: bytes
compname: bytes
_File = Union[Text, IO[bytes]]
_Marker = Tuple[int, int, bytes]
class Aifc_read:
def __init__(self, f: _File) -> None: ...
if sys.version_info >= (3, 4):
def __enter__(self) -> Aifc_read: ...
def __exit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException],
exc_tb: Optional[TracebackType]) -> None: ...
def initfp(self, file: IO[bytes]) -> None: ...
def getfp(self) -> IO[bytes]: ...
def rewind(self) -> None: ...
def close(self) -> None: ...
def tell(self) -> int: ...
def getnchannels(self) -> int: ...
def getnframes(self) -> int: ...
def getsampwidth(self) -> int: ...
def getframerate(self) -> int: ...
def getcomptype(self) -> bytes: ...
def getcompname(self) -> bytes: ...
def getparams(self) -> _aifc_params: ...
def getmarkers(self) -> Optional[List[_Marker]]: ...
def getmark(self, id: int) -> _Marker: ...
def setpos(self, pos: int) -> None: ...
def readframes(self, nframes: int) -> bytes: ...
class Aifc_write:
def __init__(self, f: _File) -> None: ...
def __del__(self) -> None: ...
if sys.version_info >= (3, 4):
def __enter__(self) -> Aifc_write: ...
def __exit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException],
exc_tb: Optional[TracebackType]) -> None: ...
def initfp(self, file: IO[bytes]) -> None: ...
def aiff(self) -> None: ...
def aifc(self) -> None: ...
def setnchannels(self, nchannels: int) -> None: ...
def getnchannels(self) -> int: ...
def setsampwidth(self, sampwidth: int) -> None: ...
def getsampwidth(self) -> int: ...
def setframerate(self, framerate: int) -> None: ...
def getframerate(self) -> int: ...
def setnframes(self, nframes: int) -> None: ...
def getnframes(self) -> int: ...
def setcomptype(self, comptype: bytes, compname: bytes) -> None: ...
def getcomptype(self) -> bytes: ...
def getcompname(self) -> bytes: ...
def setparams(self, params: Tuple[int, int, int, int, bytes, bytes]) -> None: ...
def getparams(self) -> _aifc_params: ...
def setmark(self, id: int, pos: int, name: bytes) -> None: ...
def getmark(self, id: int) -> _Marker: ...
def getmarkers(self) -> Optional[List[_Marker]]: ...
def tell(self) -> int: ...
def writeframesraw(self, data: Any) -> None: ... # Actual type for data is Buffer Protocol
def writeframes(self, data: Any) -> None: ...
def close(self) -> None: ...
@overload
def open(f: _File, mode: Literal["r", "rb"] = ...) -> Aifc_read: ...
@overload
def open(f: _File, mode: Literal["w", "wb"]) -> Aifc_write: ...
@overload
def open(f: _File, mode: str) -> Any: ...
@overload
def openfp(f: _File, mode: Literal["r", "rb"] = ...) -> Aifc_read: ...
@overload
def openfp(f: _File, mode: Literal["w", "wb"]) -> Aifc_write: ...
@overload
def openfp(f: _File, mode: str) -> Any: ...
+124 -130
View File
@@ -1,13 +1,11 @@
# Stubs for argparse (Python 2.7 and 3.4)
from typing import (
Any, Callable, Dict, Generator, Iterable, List, IO, NoReturn, Optional,
Pattern, Sequence, Tuple, Type, Union, TypeVar, overload
Pattern, Sequence, Text, Tuple, Type, Union, TypeVar, overload
)
import sys
_T = TypeVar('_T')
_ActionT = TypeVar('_ActionT', bound='Action')
_ActionT = TypeVar('_ActionT', bound=Action)
_N = TypeVar('_N')
if sys.version_info >= (3,):
@@ -46,38 +44,38 @@ class _ActionsContainer:
_negative_number_matcher: Pattern[str]
_has_negative_number_optionals: List[bool]
def __init__(self, description: Optional[_Text], prefix_chars: _Text,
argument_default: Optional[_Text], conflict_handler: _Text) -> None: ...
def register(self, registry_name: _Text, value: Any, object: Any) -> None: ...
def _registry_get(self, registry_name: _Text, value: Any, default: Any = ...) -> Any: ...
def __init__(self, description: Optional[Text], prefix_chars: Text,
argument_default: Optional[Text], conflict_handler: Text) -> None: ...
def register(self, registry_name: Text, value: Any, object: Any) -> None: ...
def _registry_get(self, registry_name: Text, value: Any, default: Any = ...) -> Any: ...
def set_defaults(self, **kwargs: Any) -> None: ...
def get_default(self, dest: _Text) -> Any: ...
def get_default(self, dest: Text) -> Any: ...
def add_argument(self,
*name_or_flags: _Text,
action: Union[_Text, Type[Action]] = ...,
nargs: Union[int, _Text] = ...,
*name_or_flags: Text,
action: Union[Text, Type[Action]] = ...,
nargs: Union[int, Text] = ...,
const: Any = ...,
default: Any = ...,
type: Union[Callable[[str], _T], FileType] = ...,
type: Union[Callable[[Text], _T], Callable[[str], _T], FileType] = ...,
choices: Iterable[_T] = ...,
required: bool = ...,
help: Optional[_Text] = ...,
metavar: Optional[Union[_Text, Tuple[_Text, ...]]] = ...,
dest: Optional[_Text] = ...,
version: _Text = ...,
help: Optional[Text] = ...,
metavar: Optional[Union[Text, Tuple[Text, ...]]] = ...,
dest: Optional[Text] = ...,
version: Text = ...,
**kwargs: Any) -> Action: ...
def add_argument_group(self, *args: Any, **kwargs: Any) -> _ArgumentGroup: ...
def add_mutually_exclusive_group(self, **kwargs: Any) -> _MutuallyExclusiveGroup: ...
def _add_action(self, action: _ActionT) -> _ActionT: ...
def _remove_action(self, action: Action) -> None: ...
def _add_container_actions(self, container: _ActionsContainer) -> None: ...
def _get_positional_kwargs(self, dest: _Text, **kwargs: Any) -> Dict[str, Any]: ...
def _get_positional_kwargs(self, dest: Text, **kwargs: Any) -> Dict[str, Any]: ...
def _get_optional_kwargs(self, *args: Any, **kwargs: Any) -> Dict[str, Any]: ...
def _pop_action_class(self, kwargs: Any, default: Optional[Type[Action]] = ...) -> Type[Action]: ...
def _get_handler(self) -> Callable[[Action, Iterable[Tuple[_Text, Action]]], Any]: ...
def _get_handler(self) -> Callable[[Action, Iterable[Tuple[Text, Action]]], Any]: ...
def _check_conflict(self, action: Action) -> None: ...
def _handle_conflict_error(self, action: Action, conflicting_actions: Iterable[Tuple[_Text, Action]]) -> NoReturn: ...
def _handle_conflict_resolve(self, action: Action, conflicting_actions: Iterable[Tuple[_Text, Action]]) -> None: ...
def _handle_conflict_error(self, action: Action, conflicting_actions: Iterable[Tuple[Text, Action]]) -> NoReturn: ...
def _handle_conflict_resolve(self, action: Action, conflicting_actions: Iterable[Tuple[Text, Action]]) -> None: ...
class ArgumentParser(_AttributeHolder, _ActionsContainer):
prog: _Text
@@ -103,88 +101,88 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
epilog: Optional[str] = ...,
parents: Sequence[ArgumentParser] = ...,
formatter_class: Type[HelpFormatter] = ...,
prefix_chars: _Text = ...,
prefix_chars: str = ...,
fromfile_prefix_chars: Optional[str] = ...,
argument_default: Optional[str] = ...,
conflict_handler: _Text = ...,
conflict_handler: str = ...,
add_help: bool = ...,
allow_abbrev: bool = ...) -> None: ...
else:
def __init__(self,
prog: Optional[_Text] = ...,
usage: Optional[_Text] = ...,
description: Optional[_Text] = ...,
epilog: Optional[_Text] = ...,
prog: Optional[Text] = ...,
usage: Optional[Text] = ...,
description: Optional[Text] = ...,
epilog: Optional[Text] = ...,
parents: Sequence[ArgumentParser] = ...,
formatter_class: Type[HelpFormatter] = ...,
prefix_chars: _Text = ...,
fromfile_prefix_chars: Optional[_Text] = ...,
argument_default: Optional[_Text] = ...,
conflict_handler: _Text = ...,
prefix_chars: Text = ...,
fromfile_prefix_chars: Optional[Text] = ...,
argument_default: Optional[Text] = ...,
conflict_handler: Text = ...,
add_help: bool = ...) -> None: ...
# The type-ignores in these overloads should be temporary. See:
# https://github.com/python/typeshed/pull/2643#issuecomment-442280277
@overload
def parse_args(self, args: Optional[Sequence[_Text]] = ...) -> Namespace: ...
def parse_args(self, args: Optional[Sequence[Text]] = ...) -> Namespace: ...
@overload
def parse_args(self, args: Optional[Sequence[_Text]], namespace: None) -> Namespace: ... # type: ignore
def parse_args(self, args: Optional[Sequence[Text]], namespace: None) -> Namespace: ... # type: ignore
@overload
def parse_args(self, args: Optional[Sequence[_Text]], namespace: _N) -> _N: ...
def parse_args(self, args: Optional[Sequence[Text]], namespace: _N) -> _N: ...
@overload
def parse_args(self, *, namespace: None) -> Namespace: ... # type: ignore
@overload
def parse_args(self, *, namespace: _N) -> _N: ...
if sys.version_info >= (3, 7):
def add_subparsers(self, title: _Text = ...,
description: Optional[_Text] = ...,
prog: _Text = ...,
def add_subparsers(self, title: str = ...,
description: Optional[str] = ...,
prog: str = ...,
parser_class: Type[ArgumentParser] = ...,
action: Type[Action] = ...,
option_string: _Text = ...,
dest: Optional[_Text] = ...,
option_string: str = ...,
dest: Optional[str] = ...,
required: bool = ...,
help: Optional[_Text] = ...,
metavar: Optional[_Text] = ...) -> _SubParsersAction: ...
help: Optional[str] = ...,
metavar: Optional[str] = ...) -> _SubParsersAction: ...
else:
def add_subparsers(self, title: _Text = ...,
description: Optional[_Text] = ...,
prog: _Text = ...,
def add_subparsers(self, title: Text = ...,
description: Optional[Text] = ...,
prog: Text = ...,
parser_class: Type[ArgumentParser] = ...,
action: Type[Action] = ...,
option_string: _Text = ...,
dest: Optional[_Text] = ...,
help: Optional[_Text] = ...,
metavar: Optional[_Text] = ...) -> _SubParsersAction: ...
option_string: Text = ...,
dest: Optional[Text] = ...,
help: Optional[Text] = ...,
metavar: Optional[Text] = ...) -> _SubParsersAction: ...
def print_usage(self, file: Optional[IO[str]] = ...) -> None: ...
def print_help(self, file: Optional[IO[str]] = ...) -> None: ...
def format_usage(self) -> str: ...
def format_help(self) -> str: ...
def parse_known_args(self, args: Optional[Sequence[_Text]] = ...,
def parse_known_args(self, args: Optional[Sequence[Text]] = ...,
namespace: Optional[Namespace] = ...) -> Tuple[Namespace, List[str]]: ...
def convert_arg_line_to_args(self, arg_line: _Text) -> List[str]: ...
def exit(self, status: int = ..., message: Optional[_Text] = ...) -> NoReturn: ...
def error(self, message: _Text) -> NoReturn: ...
def convert_arg_line_to_args(self, arg_line: Text) -> List[str]: ...
def exit(self, status: int = ..., message: Optional[Text] = ...) -> NoReturn: ...
def error(self, message: Text) -> NoReturn: ...
if sys.version_info >= (3, 7):
def parse_intermixed_args(self, args: Optional[Sequence[_Text]] = ...,
def parse_intermixed_args(self, args: Optional[Sequence[str]] = ...,
namespace: Optional[Namespace] = ...) -> Namespace: ...
def parse_known_intermixed_args(self,
args: Optional[Sequence[_Text]] = ...,
args: Optional[Sequence[str]] = ...,
namespace: Optional[Namespace] = ...) -> Tuple[Namespace, List[str]]: ...
# undocumented
def _get_optional_actions(self) -> List[Action]: ...
def _get_positional_actions(self) -> List[Action]: ...
def _parse_known_args(self, arg_strings: List[_Text], namespace: Namespace) -> Tuple[Namespace, List[str]]: ...
def _read_args_from_files(self, arg_strings: List[_Text]) -> List[_Text]: ...
def _match_argument(self, action: Action, arg_strings_pattern: _Text) -> int: ...
def _match_arguments_partial(self, actions: Sequence[Action], arg_strings_pattern: _Text) -> List[int]: ...
def _parse_optional(self, arg_string: _Text) -> Optional[Tuple[Optional[Action], _Text, Optional[_Text]]]: ...
def _get_option_tuples(self, option_string: _Text) -> List[Tuple[Action, _Text, Optional[_Text]]]: ...
def _parse_known_args(self, arg_strings: List[Text], namespace: Namespace) -> Tuple[Namespace, List[str]]: ...
def _read_args_from_files(self, arg_strings: List[Text]) -> List[Text]: ...
def _match_argument(self, action: Action, arg_strings_pattern: Text) -> int: ...
def _match_arguments_partial(self, actions: Sequence[Action], arg_strings_pattern: Text) -> List[int]: ...
def _parse_optional(self, arg_string: Text) -> Optional[Tuple[Optional[Action], Text, Optional[Text]]]: ...
def _get_option_tuples(self, option_string: Text) -> List[Tuple[Action, Text, Optional[Text]]]: ...
def _get_nargs_pattern(self, action: Action) -> _Text: ...
def _get_values(self, action: Action, arg_strings: List[_Text]) -> Any: ...
def _get_value(self, action: Action, arg_string: _Text) -> Any: ...
def _get_values(self, action: Action, arg_strings: List[Text]) -> Any: ...
def _get_value(self, action: Action, arg_string: Text) -> Any: ...
def _check_value(self, action: Action, value: Any) -> None: ...
def _get_formatter(self) -> HelpFormatter: ...
def _print_message(self, message: str, file: Optional[IO[str]] = ...) -> None: ...
@@ -203,31 +201,31 @@ class HelpFormatter:
_whitespace_matcher: Pattern[str]
_long_break_matcher: Pattern[str]
_Section: Type[Any] # Nested class
def __init__(self, prog: _Text, indent_increment: int = ...,
def __init__(self, prog: Text, indent_increment: int = ...,
max_help_position: int = ...,
width: Optional[int] = ...) -> None: ...
def _indent(self) -> None: ...
def _dedent(self) -> None: ...
def _add_item(self, func: Callable[..., _Text], args: Iterable[Any]) -> None: ...
def start_section(self, heading: Optional[_Text]) -> None: ...
def start_section(self, heading: Optional[Text]) -> None: ...
def end_section(self) -> None: ...
def add_text(self, text: Optional[_Text]) -> None: ...
def add_usage(self, usage: _Text, actions: Iterable[Action], groups: Iterable[_ArgumentGroup], prefix: Optional[_Text] = ...) -> None: ...
def add_text(self, text: Optional[Text]) -> None: ...
def add_usage(self, usage: Text, actions: Iterable[Action], groups: Iterable[_ArgumentGroup], prefix: Optional[Text] = ...) -> None: ...
def add_argument(self, action: Action) -> None: ...
def add_arguments(self, actions: Iterable[Action]) -> None: ...
def format_help(self) -> _Text: ...
def _join_parts(self, part_strings: Iterable[_Text]) -> _Text: ...
def _format_usage(self, usage: _Text, actions: Iterable[Action], groups: Iterable[_ArgumentGroup], prefix: Optional[_Text]) -> _Text: ...
def _join_parts(self, part_strings: Iterable[Text]) -> _Text: ...
def _format_usage(self, usage: Text, actions: Iterable[Action], groups: Iterable[_ArgumentGroup], prefix: Optional[Text]) -> _Text: ...
def _format_actions_usage(self, actions: Iterable[Action], groups: Iterable[_ArgumentGroup]) -> _Text: ...
def _format_text(self, text: _Text) -> _Text: ...
def _format_text(self, text: Text) -> _Text: ...
def _format_action(self, action: Action) -> _Text: ...
def _format_action_invocation(self, action: Action) -> _Text: ...
def _metavar_formatter(self, action: Action, default_metavar: _Text) -> Callable[[int], Tuple[_Text, ...]]: ...
def _format_args(self, action: Action, default_metavar: _Text) -> _Text: ...
def _metavar_formatter(self, action: Action, default_metavar: Text) -> Callable[[int], Tuple[_Text, ...]]: ...
def _format_args(self, action: Action, default_metavar: Text) -> _Text: ...
def _expand_help(self, action: Action) -> _Text: ...
def _iter_indented_subactions(self, action: Action) -> Generator[Action, None, None]: ...
def _split_lines(self, text: _Text, width: int) -> List[_Text]: ...
def _fill_text(self, text: _Text, width: int, indent: int) -> _Text: ...
def _split_lines(self, text: Text, width: int) -> List[_Text]: ...
def _fill_text(self, text: Text, width: int, indent: Text) -> _Text: ...
def _get_help_string(self, action: Action) -> Optional[_Text]: ...
def _get_default_metavar_for_optional(self, action: Action) -> _Text: ...
def _get_default_metavar_for_positional(self, action: Action) -> _Text: ...
@@ -251,52 +249,48 @@ class Action(_AttributeHolder):
metavar: Optional[Union[_Text, Tuple[_Text, ...]]]
def __init__(self,
option_strings: Sequence[_Text],
dest: _Text,
nargs: Optional[Union[int, _Text]] = ...,
option_strings: Sequence[Text],
dest: Text,
nargs: Optional[Union[int, Text]] = ...,
const: Any = ...,
default: Any = ...,
type: Optional[Union[Callable[[str], _T], FileType]] = ...,
type: Optional[Union[Callable[[Text], _T], Callable[[str], _T], FileType]] = ...,
choices: Optional[Iterable[_T]] = ...,
required: bool = ...,
help: Optional[_Text] = ...,
metavar: Optional[Union[_Text, Tuple[_Text, ...]]] = ...) -> None: ...
help: Optional[Text] = ...,
metavar: Optional[Union[Text, Tuple[Text, ...]]] = ...) -> None: ...
def __call__(self, parser: ArgumentParser, namespace: Namespace,
values: Union[_Text, Sequence[Any], None],
option_string: Optional[_Text] = ...) -> None: ...
values: Union[Text, Sequence[Any], None],
option_string: Optional[Text] = ...) -> None: ...
class Namespace(_AttributeHolder):
def __init__(self, **kwargs: Any) -> None: ...
def __getattr__(self, name: _Text) -> Any: ...
def __setattr__(self, name: _Text, value: Any) -> None: ...
def __getattr__(self, name: Text) -> Any: ...
def __setattr__(self, name: Text, value: Any) -> None: ...
def __contains__(self, key: str) -> bool: ...
class FileType:
# undocumented
_mode: _Text
_bufsize: int
if sys.version_info >= (3, 4):
_encoding: Optional[_Text]
_errors: Optional[_Text]
if sys.version_info >= (3, 4):
def __init__(self, mode: _Text = ..., bufsize: int = ...,
encoding: Optional[_Text] = ...,
errors: Optional[_Text] = ...) -> None: ...
elif sys.version_info >= (3,):
def __init__(self,
mode: _Text = ..., bufsize: int = ...) -> None: ...
if sys.version_info >= (3,):
_encoding: Optional[str]
_errors: Optional[str]
def __init__(self, mode: str = ..., bufsize: int = ...,
encoding: Optional[str] = ...,
errors: Optional[str] = ...) -> None: ...
else:
def __init__(self,
mode: _Text = ..., bufsize: Optional[int] = ...) -> None: ...
def __call__(self, string: _Text) -> IO[Any]: ...
mode: Text = ..., bufsize: Optional[int] = ...) -> None: ...
def __call__(self, string: Text) -> IO[Any]: ...
# undocumented
class _ArgumentGroup(_ActionsContainer):
title: Optional[_Text]
_group_actions: List[Action]
def __init__(self, container: _ActionsContainer,
title: Optional[_Text] = ...,
description: Optional[_Text] = ..., **kwargs: Any) -> None: ...
title: Optional[Text] = ...,
description: Optional[Text] = ..., **kwargs: Any) -> None: ...
# undocumented
class _MutuallyExclusiveGroup(_ArgumentGroup):
@@ -310,31 +304,31 @@ class _StoreAction(Action): ...
# undocumented
class _StoreConstAction(Action):
def __init__(self,
option_strings: Sequence[_Text],
dest: _Text,
option_strings: Sequence[Text],
dest: Text,
const: Any,
default: Any = ...,
required: bool = ...,
help: Optional[_Text] = ...,
metavar: Optional[Union[_Text, Tuple[_Text, ...]]] = ...) -> None: ...
help: Optional[Text] = ...,
metavar: Optional[Union[Text, Tuple[Text, ...]]] = ...) -> None: ...
# undocumented
class _StoreTrueAction(_StoreConstAction):
def __init__(self,
option_strings: Sequence[_Text],
dest: _Text,
option_strings: Sequence[Text],
dest: Text,
default: bool = ...,
required: bool = ...,
help: Optional[_Text] = ...) -> None: ...
help: Optional[Text] = ...) -> None: ...
# undocumented
class _StoreFalseAction(_StoreConstAction):
def __init__(self,
option_strings: Sequence[_Text],
dest: _Text,
option_strings: Sequence[Text],
dest: Text,
default: bool = ...,
required: bool = ...,
help: Optional[_Text] = ...) -> None: ...
help: Optional[Text] = ...) -> None: ...
# undocumented
class _AppendAction(Action): ...
@@ -342,40 +336,40 @@ class _AppendAction(Action): ...
# undocumented
class _AppendConstAction(Action):
def __init__(self,
option_strings: Sequence[_Text],
dest: _Text,
option_strings: Sequence[Text],
dest: Text,
const: Any,
default: Any = ...,
required: bool = ...,
help: Optional[_Text] = ...,
metavar: Optional[Union[_Text, Tuple[_Text, ...]]] = ...) -> None: ...
help: Optional[Text] = ...,
metavar: Optional[Union[Text, Tuple[Text, ...]]] = ...) -> None: ...
# undocumented
class _CountAction(Action):
def __init__(self,
option_strings: Sequence[_Text],
dest: _Text,
option_strings: Sequence[Text],
dest: Text,
default: Any = ...,
required: bool = ...,
help: Optional[_Text] = ...) -> None: ...
help: Optional[Text] = ...) -> None: ...
# undocumented
class _HelpAction(Action):
def __init__(self,
option_strings: Sequence[_Text],
dest: _Text = ...,
default: _Text = ...,
help: Optional[_Text] = ...) -> None: ...
option_strings: Sequence[Text],
dest: Text = ...,
default: Text = ...,
help: Optional[Text] = ...) -> None: ...
# undocumented
class _VersionAction(Action):
version: Optional[_Text]
def __init__(self,
option_strings: Sequence[_Text],
version: Optional[_Text] = ...,
dest: _Text = ...,
default: _Text = ...,
help: _Text = ...) -> None: ...
option_strings: Sequence[Text],
version: Optional[Text] = ...,
dest: Text = ...,
default: Text = ...,
help: Text = ...) -> None: ...
# undocumented
class _SubParsersAction(Action):
@@ -386,15 +380,15 @@ class _SubParsersAction(Action):
choices: Dict[_Text, ArgumentParser]
_choices_actions: List[Action]
def __init__(self,
option_strings: Sequence[_Text],
prog: _Text,
option_strings: Sequence[Text],
prog: Text,
parser_class: Type[ArgumentParser],
dest: _Text = ...,
dest: Text = ...,
required: bool = ...,
help: Optional[_Text] = ...,
metavar: Optional[Union[_Text, Tuple[_Text, ...]]] = ...) -> None: ...
help: Optional[Text] = ...,
metavar: Optional[Union[Text, Tuple[Text, ...]]] = ...) -> None: ...
# TODO: Type keyword args properly.
def add_parser(self, name: _Text, **kwargs: Any) -> ArgumentParser: ...
def add_parser(self, name: Text, **kwargs: Any) -> ArgumentParser: ...
def _get_subactions(self) -> List[Action]: ...
# undocumented
@@ -402,7 +396,7 @@ class ArgumentTypeError(Exception): ...
if sys.version_info < (3, 7):
# undocumented
def _ensure_value(namespace: Namespace, name: _Text, value: Any) -> Any: ...
def _ensure_value(namespace: Namespace, name: Text, value: Any) -> Any: ...
# undocumented
def _get_action_name(argument: Optional[Action]) -> Optional[str]: ...
+5 -4
View File
@@ -13,8 +13,9 @@ from errno import (EALREADY, EINPROGRESS, EWOULDBLOCK, ECONNRESET, EINVAL,
EPIPE, EAGAIN, errorcode)
# cyclic dependence with asynchat
_maptype = Dict[str, Any]
_maptype = Dict[int, Any]
socket_map: _maptype = ... # Undocumented
class ExitNow(Exception): ...
@@ -50,8 +51,8 @@ class dispatcher:
def readable(self) -> bool: ...
def writable(self) -> bool: ...
def listen(self, backlog: int) -> None: ...
def bind(self, address: Union[tuple, str]) -> None: ...
def connect(self, address: Union[tuple, str]) -> None: ...
def bind(self, address: Union[Tuple[Any, ...], str]) -> None: ...
def connect(self, address: Union[Tuple[Any, ...], str]) -> None: ...
def accept(self) -> Optional[Tuple[SocketType, Any]]: ...
def send(self, data: bytes) -> int: ...
def recv(self, buffer_size: int) -> bytes: ...
@@ -103,7 +104,7 @@ class dispatcher:
def recvfrom_into(self, buffer: bytes, nbytes: int, flags: int = ...) -> Any: ...
def recv_into(self, buffer: bytes, nbytes: int, flags: int = ...) -> Any: ...
def sendall(self, data: bytes, flags: int = ...) -> None: ...
def sendto(self, data: bytes, address: Union[tuple, str], flags: int = ...) -> int: ...
def sendto(self, data: bytes, address: Union[Tuple[str, int], str], flags: int = ...) -> int: ...
def setblocking(self, flag: bool) -> None: ...
def settimeout(self, value: Union[float, None]) -> None: ...
def setsockopt(self, level: int, optname: int, value: Union[int, bytes]) -> None: ...
+42
View File
@@ -0,0 +1,42 @@
from typing import Any, Optional, Tuple
AdpcmState = Tuple[int, int]
RatecvState = Tuple[int, Tuple[Tuple[int, int], ...]]
class error(Exception): ...
def add(fragment1: bytes, fragment2: bytes, width: int) -> bytes: ...
def adpcm2lin(adpcmfragment: bytes, width: int, state: Optional[AdpcmState]) -> Tuple[bytes, AdpcmState]: ...
def alaw2lin(fragment: bytes, width: int) -> bytes: ...
def avg(fragment: bytes, width: int) -> int: ...
def avgpp(fragment: bytes, width: int) -> int: ...
def bias(fragment: bytes, width: int, bias: int) -> bytes: ...
def byteswap(fragment: bytes, width: int) -> bytes: ...
def cross(fragment: bytes, width: int) -> int: ...
def findfactor(fragment: bytes, reference: bytes) -> float: ...
def findfit(fragment: bytes, reference: bytes) -> Tuple[int, float]: ...
def findmax(fragment: bytes, length: int) -> int: ...
def getsample(fragment: bytes, width: int, index: int) -> int: ...
def lin2adpcm(fragment: bytes, width: int, state: Optional[AdpcmState]) -> Tuple[bytes, AdpcmState]: ...
def lin2alaw(fragment: bytes, width: int) -> bytes: ...
def lin2lin(fragment: bytes, width: int, newwidth: int) -> bytes: ...
def lin2ulaw(fragment: bytes, width: int) -> bytes: ...
def max(fragment: bytes, width: int) -> int: ...
def maxpp(fragment: bytes, width: int) -> int: ...
def minmax(fragment: bytes, width: int) -> Tuple[int, int]: ...
def mul(fragment: bytes, width: int, factor: float) -> bytes: ...
def ratecv(
fragment: bytes,
width: int,
nchannels: int,
inrate: int,
outrate: int,
state: Optional[RatecvState],
weightA: int = ...,
weightB: int = ...,
) -> Tuple[bytes, RatecvState]: ...
def reverse(fragment: bytes, width: int) -> bytes: ...
def rms(fragment: bytes, width: int) -> int: ...
def tomono(fragment: bytes, width: int, lfactor: float, rfactor: float) -> bytes: ...
def tostereo(fragment: bytes, width: int, lfactor: float, rfactor: float) -> bytes: ...
def ulaw2lin(fragment: bytes, width: int) -> bytes: ...
+94
View File
@@ -0,0 +1,94 @@
from typing import Set, Dict, Iterable, Any, Callable, Tuple, Type, SupportsInt, List, Union, TypeVar, Optional, IO
from types import FrameType, TracebackType, CodeType
_T = TypeVar("_T")
_TraceDispatch = Callable[[FrameType, str, Any], Any] # TODO: Recursive type
_ExcInfo = Tuple[Type[BaseException], BaseException, FrameType]
GENERATOR_AND_COROUTINE_FLAGS: int = ...
class BdbQuit(Exception): ...
class Bdb:
skip: Optional[Set[str]]
breaks: Dict[str, List[int]]
fncache: Dict[str, str]
frame_returning: Optional[FrameType]
botframe: Optional[FrameType]
quitting: bool
stopframe: Optional[FrameType]
returnframe: Optional[FrameType]
stoplineno: int
def __init__(self, skip: Iterable[str] = ...) -> None: ...
def canonic(self, filename: str) -> str: ...
def reset(self) -> None: ...
def trace_dispatch(self, frame: FrameType, event: str, arg: Any) -> _TraceDispatch: ...
def dispatch_line(self, frame: FrameType) -> _TraceDispatch: ...
def dispatch_call(self, frame: FrameType, arg: None) -> _TraceDispatch: ...
def dispatch_return(self, frame: FrameType, arg: Any) -> _TraceDispatch: ...
def dispatch_exception(self, frame: FrameType, arg: _ExcInfo) -> _TraceDispatch: ...
def is_skipped_module(self, module_name: str) -> bool: ...
def stop_here(self, frame: FrameType) -> bool: ...
def break_here(self, frame: FrameType) -> bool: ...
def do_clear(self, arg: Any) -> None: ...
def break_anywhere(self, frame: FrameType) -> bool: ...
def user_call(self, frame: FrameType, argument_list: None) -> None: ...
def user_line(self, frame: FrameType) -> None: ...
def user_return(self, frame: FrameType, return_value: Any) -> None: ...
def user_exception(self, frame: FrameType, exc_info: _ExcInfo) -> None: ...
def set_until(self, frame: FrameType, lineno: Optional[int] = ...) -> None: ...
def set_step(self) -> None: ...
def set_next(self, frame: FrameType) -> None: ...
def set_return(self, frame: FrameType) -> None: ...
def set_trace(self, frame: Optional[FrameType] = ...) -> None: ...
def set_continue(self) -> None: ...
def set_quit(self) -> None: ...
def set_break(self, filename: str, lineno: int, temporary: bool = ..., cond: Optional[str] = ..., funcname: Optional[str] = ...) -> None: ...
def clear_break(self, filename: str, lineno: int) -> None: ...
def clear_bpbynumber(self, arg: SupportsInt) -> None: ...
def clear_all_file_breaks(self, filename: str) -> None: ...
def clear_all_breaks(self) -> None: ...
def get_bpbynumber(self, arg: SupportsInt) -> Breakpoint: ...
def get_break(self, filename: str, lineno: int) -> bool: ...
def get_breaks(self, filename: str, lineno: int) -> List[Breakpoint]: ...
def get_file_breaks(self, filename: str) -> List[Breakpoint]: ...
def get_all_breaks(self) -> List[Breakpoint]: ...
def get_stack(self, f: FrameType, t: TracebackType) -> Tuple[List[Tuple[FrameType, int]], int]: ...
def format_stack_entry(self, frame_lineno: int, lprefix: str = ...) -> str: ...
def run(self, cmd: Union[str, CodeType], globals: Dict[str, Any] = ..., locals: Dict[str, Any] = ...) -> None: ...
def runeval(self, expr: str, globals: Dict[str, Any] = ..., locals: Dict[str, Any] = ...) -> None: ...
def runctx(self, cmd: Union[str, CodeType], globals: Dict[str, Any], locals: Dict[str, Any]) -> None: ...
def runcall(self, func: Callable[[Any], _T], *args: Any, **kwds: Any) -> Optional[_T]: ...
class Breakpoint:
next: int = ...
bplist: Dict[Tuple[str, int], List[Breakpoint]] = ...
bpbynumber: List[Optional[Breakpoint]] = ...
funcname: Optional[str]
func_first_executable_line: Optional[int]
file: str
line: int
temporary: bool
cond: Optional[str]
enabled: bool
ignore: int
hits: int
number: int
def __init__(self, file: str, line: int, temporary: bool = ..., cond: Optional[str] = ..., funcname: Optional[str] = ...) -> None: ...
def deleteMe(self) -> None: ...
def enable(self) -> None: ...
def disable(self) -> None: ...
def bpprint(self, out: Optional[IO[str]] = ...) -> None: ...
def bpformat(self) -> str: ...
def __str__(self) -> str: ...
def checkfuncname(b: Breakpoint, frame: FrameType) -> bool: ...
def effective(file: str, line: int, frame: FrameType) -> Union[Tuple[Breakpoint, bool], Tuple[None, None]]: ...
def set_trace() -> None: ...
+3 -8
View File
@@ -5,20 +5,15 @@
import sys
from typing import Union, Text
if sys.version_info < (3,):
# Python 2 accepts unicode ascii pretty much everywhere.
_Bytes = Union[bytes, Text]
_Ascii = Union[bytes, Text]
elif sys.version_info < (3, 3):
# Python 3.2 and below only accepts bytes.
_Bytes = bytes
_Ascii = bytes
_Bytes = Text
_Ascii = Text
else:
# But since Python 3.3 ASCII-only unicode strings are accepted by the
# a2b_* functions.
_Bytes = bytes
_Ascii = Union[bytes, Text]
_Ascii = Union[bytes, str]
def a2b_uu(string: _Ascii) -> bytes: ...
if sys.version_info >= (3, 7):
+7 -16
View File
@@ -1,22 +1,13 @@
# Stubs for bisect
from typing import Any, Sequence, TypeVar
from typing import Any, Sequence, MutableSequence, TypeVar
_T = TypeVar('_T')
# TODO uncomment when mypy# 2035 is fixed
# def bisect_left(a: Sequence[_T], x: _T, lo: int = ..., hi: int = ...) -> int: ...
# def bisect_right(a: Sequence[_T], x: _T, lo: int = ..., hi: int = ...) -> int: ...
# def bisect(a: Sequence[_T], x: _T, lo: int = ..., hi: int = ...) -> int: ...
#
# def insort_left(a: Sequence[_T], x: _T, lo: int = ..., hi: int = ...) -> int: ...
# def insort_right(a: Sequence[_T], x: _T, lo: int = ..., hi: int = ...) -> int: ...
# def insort(a: Sequence[_T], x: _T, lo: int = ..., hi: int = ...) -> int: ...
def bisect_left(a: Sequence[_T], x: _T, lo: int = ..., hi: int = ...) -> int: ...
def bisect_right(a: Sequence[_T], x: _T, lo: int = ..., hi: int = ...) -> int: ...
def bisect(a: Sequence[_T], x: _T, lo: int = ..., hi: int = ...) -> int: ...
def bisect_left(a: Sequence, x: Any, lo: int = ..., hi: int = ...) -> int: ...
def bisect_right(a: Sequence, x: Any, lo: int = ..., hi: int = ...) -> int: ...
def bisect(a: Sequence, x: Any, lo: int = ..., hi: int = ...) -> int: ...
def insort_left(a: Sequence, x: Any, lo: int = ..., hi: int = ...) -> int: ...
def insort_right(a: Sequence, x: Any, lo: int = ..., hi: int = ...) -> int: ...
def insort(a: Sequence, x: Any, lo: int = ..., hi: int = ...) -> int: ...
def insort_left(a: MutableSequence[_T], x: _T, lo: int = ..., hi: int = ...) -> int: ...
def insort_right(a: MutableSequence[_T], x: _T, lo: int = ..., hi: int = ...) -> int: ...
def insort(a: MutableSequence[_T], x: _T, lo: int = ..., hi: int = ...) -> int: ...
+87 -59
View File
@@ -17,6 +17,11 @@ import sys
if sys.version_info >= (3,):
from typing import SupportsBytes, SupportsRound
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
_T = TypeVar('_T')
_T_co = TypeVar('_T_co', covariant=True)
_KT = TypeVar('_KT')
@@ -29,6 +34,9 @@ _T4 = TypeVar('_T4')
_T5 = TypeVar('_T5')
_TT = TypeVar('_TT', bound='type')
class _SupportsIndex(Protocol):
def __index__(self) -> int: ...
class object:
__doc__: Optional[str]
__dict__: Dict[str, Any]
@@ -53,30 +61,30 @@ class object:
def __getattribute__(self, name: str) -> Any: ...
def __delattr__(self, name: str) -> None: ...
def __sizeof__(self) -> int: ...
def __reduce__(self) -> tuple: ...
def __reduce_ex__(self, protocol: int) -> tuple: ...
def __reduce__(self) -> Union[str, Tuple[Any, ...]]: ...
def __reduce_ex__(self, protocol: int) -> Union[str, Tuple[Any, ...]]: ...
if sys.version_info >= (3,):
def __dir__(self) -> Iterable[str]: ...
if sys.version_info >= (3, 6):
def __init_subclass__(cls) -> None: ...
class staticmethod(object): # Special, only valid as a decorator.
__func__: Callable
__func__: Callable[..., Any]
if sys.version_info >= (3,):
__isabstractmethod__: bool
def __init__(self, f: Callable) -> None: ...
def __init__(self, f: Callable[..., Any]) -> None: ...
def __new__(cls: Type[_T], *args: Any, **kwargs: Any) -> _T: ...
def __get__(self, obj: _T, type: Optional[Type[_T]] = ...) -> Callable: ...
def __get__(self, obj: _T, type: Optional[Type[_T]] = ...) -> Callable[..., Any]: ...
class classmethod(object): # Special, only valid as a decorator.
__func__: Callable
__func__: Callable[..., Any]
if sys.version_info >= (3,):
__isabstractmethod__: bool
def __init__(self, f: Callable) -> None: ...
def __init__(self, f: Callable[..., Any]) -> None: ...
def __new__(cls: Type[_T], *args: Any, **kwargs: Any) -> _T: ...
def __get__(self, obj: _T, type: Optional[Type[_T]] = ...) -> Callable: ...
def __get__(self, obj: _T, type: Optional[Type[_T]] = ...) -> Callable[..., Any]: ...
class type(object):
__base__: type
@@ -129,10 +137,12 @@ class super(object):
class int:
@overload
def __init__(self, x: Union[Text, bytes, SupportsInt] = ...) -> None: ...
def __init__(self, x: Union[Text, bytes, SupportsInt, _SupportsIndex] = ...) -> None: ...
@overload
def __init__(self, x: Union[Text, bytes, bytearray], base: int) -> None: ...
if sys.version_info >= (3, 8):
def as_integer_ratio(self) -> Tuple[int, Literal[1]]: ...
@property
def real(self) -> int: ...
@property
@@ -168,7 +178,7 @@ class int:
def __rtruediv__(self, x: int) -> float: ...
def __rmod__(self, x: int) -> int: ...
def __rdivmod__(self, x: int) -> Tuple[int, int]: ...
def __pow__(self, x: int) -> Any: ... # Return type can be int or float, depending on x.
def __pow__(self, __x: int, __modulo: Optional[int] = ...) -> Any: ... # Return type can be int or float, depending on x.
def __rpow__(self, x: int) -> Any: ...
def __and__(self, n: int) -> int: ...
def __or__(self, n: int) -> int: ...
@@ -183,7 +193,10 @@ class int:
def __neg__(self) -> int: ...
def __pos__(self) -> int: ...
def __invert__(self) -> int: ...
def __trunc__(self) -> int: ...
if sys.version_info >= (3,):
def __ceil__(self) -> int: ...
def __floor__(self) -> int: ...
def __round__(self, ndigits: Optional[int] = ...) -> int: ...
def __getnewargs__(self) -> Tuple[int]: ...
@@ -206,7 +219,7 @@ class int:
def __index__(self) -> int: ...
class float:
def __init__(self, x: Union[SupportsFloat, Text, bytes, bytearray] = ...) -> None: ...
def __init__(self, x: Union[SupportsFloat, _SupportsIndex, Text, bytes, bytearray] = ...) -> None: ...
def as_integer_ratio(self) -> Tuple[int, int]: ...
def hex(self) -> str: ...
def is_integer(self) -> bool: ...
@@ -240,11 +253,10 @@ class float:
def __rdivmod__(self, x: float) -> Tuple[float, float]: ...
def __rpow__(self, x: float) -> float: ...
def __getnewargs__(self) -> Tuple[float]: ...
def __trunc__(self) -> int: ...
if sys.version_info >= (3,):
@overload
def __round__(self) -> int: ...
@overload
def __round__(self, ndigits: None) -> int: ...
def __round__(self, ndigits: None = ...) -> int: ...
@overload
def __round__(self, ndigits: int) -> float: ...
@@ -269,11 +281,9 @@ class float:
class complex:
@overload
def __init__(self, re: float = ..., im: float = ...) -> None: ...
def __init__(self, real: float = ..., imag: float = ...) -> None: ...
@overload
def __init__(self, s: str) -> None: ...
@overload
def __init__(self, s: SupportsComplex) -> None: ...
def __init__(self, real: Union[str, SupportsComplex, _SupportsIndex]) -> None: ...
@property
def real(self) -> float: ...
@@ -332,7 +342,7 @@ else:
end: int = ...) -> bool: ...
def expandtabs(self, tabsize: int = ...) -> unicode: ...
def find(self, sub: unicode, start: int = ..., end: int = ...) -> int: ...
def format(self, *args: Any, **kwargs: Any) -> unicode: ...
def format(self, *args: object, **kwargs: object) -> unicode: ...
def index(self, sub: unicode, start: int = ..., end: int = ...) -> int: ...
def isalnum(self) -> bool: ...
def isalpha(self) -> bool: ...
@@ -421,7 +431,7 @@ class str(Sequence[str], _str_base):
def endswith(self, suffix: Union[Text, Tuple[Text, ...]]) -> bool: ...
def expandtabs(self, tabsize: int = ...) -> str: ...
def find(self, sub: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ...
def format(self, *args: Any, **kwargs: Any) -> str: ...
def format(self, *args: object, **kwargs: object) -> str: ...
if sys.version_info >= (3,):
def format_map(self, map: Mapping[str, Any]) -> str: ...
def index(self, sub: Text, __start: Optional[int] = ..., __end: Optional[int] = ...) -> int: ...
@@ -667,6 +677,8 @@ class bytearray(MutableSequence[int], ByteString):
def decode(self, encoding: Text = ..., errors: Text = ...) -> str: ...
def endswith(self, suffix: Union[bytes, Tuple[bytes, ...]]) -> bool: ...
def expandtabs(self, tabsize: int = ...) -> bytearray: ...
if sys.version_info < (3,):
def extend(self, iterable: Union[str, Iterable[int]]) -> None: ...
if sys.version_info >= (3,):
def find(self, sub: Union[bytes, int], start: Optional[int] = ..., end: Optional[int] = ...) -> int: ...
if sys.version_info >= (3, 5):
@@ -734,7 +746,7 @@ class bytearray(MutableSequence[int], ByteString):
def __repr__(self) -> str: ...
def __int__(self) -> int: ...
def __float__(self) -> float: ...
def __hash__(self) -> int: ...
__hash__: None # type: ignore
@overload
def __getitem__(self, i: int) -> int: ...
@overload
@@ -784,9 +796,10 @@ class memoryview(Sized, Container[_mv_container_type]):
c_contiguous: bool
f_contiguous: bool
contiguous: bool
nbytes: int
def __init__(self, obj: Union[bytes, bytearray, memoryview]) -> None: ...
def __enter__(self) -> memoryview: ...
def __exit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]) -> bool: ...
def __exit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]) -> None: ...
else:
def __init__(self, obj: Union[bytes, bytearray, buffer, memoryview]) -> None: ...
@@ -799,16 +812,19 @@ class memoryview(Sized, Container[_mv_container_type]):
def __iter__(self) -> Iterator[_mv_container_type]: ...
def __len__(self) -> int: ...
@overload
def __setitem__(self, s: slice, o: memoryview) -> None: ...
@overload
def __setitem__(self, i: int, o: bytes) -> None: ...
@overload
def __setitem__(self, s: slice, o: Sequence[bytes]) -> None: ...
@overload
def __setitem__(self, s: slice, o: memoryview) -> None: ...
def tobytes(self) -> bytes: ...
def tolist(self) -> List[int]: ...
if sys.version_info >= (3, 2):
def release(self) -> None: ...
if sys.version_info >= (3, 5):
def hex(self) -> str: ...
@@ -841,13 +857,14 @@ class bool(int):
def __getnewargs__(self) -> Tuple[int]: ...
class slice(object):
start: Optional[int]
step: Optional[int]
stop: Optional[int]
start: Any
step: Any
stop: Any
@overload
def __init__(self, stop: Optional[int]) -> None: ...
def __init__(self, stop: Any) -> None: ...
@overload
def __init__(self, start: Optional[int], stop: Optional[int], step: Optional[int] = ...) -> None: ...
def __init__(self, start: Any, stop: Any, step: Any = ...) -> None: ...
__hash__: None # type: ignore
def indices(self, len: int) -> Tuple[int, int, int]: ...
class tuple(Sequence[_T_co], Generic[_T_co]):
@@ -863,7 +880,10 @@ class tuple(Sequence[_T_co], Generic[_T_co]):
def __le__(self, x: Tuple[_T_co, ...]) -> bool: ...
def __gt__(self, x: Tuple[_T_co, ...]) -> bool: ...
def __ge__(self, x: Tuple[_T_co, ...]) -> bool: ...
@overload
def __add__(self, x: Tuple[_T_co, ...]) -> Tuple[_T_co, ...]: ...
@overload
def __add__(self, x: Tuple[Any, ...]) -> Tuple[Any, ...]: ...
def __mul__(self, n: int) -> Tuple[_T_co, ...]: ...
def __rmul__(self, n: int) -> Tuple[_T_co, ...]: ...
def count(self, x: Any) -> int: ...
@@ -876,9 +896,9 @@ class function:
# TODO not defined in builtins!
__name__: str
__module__: str
__code__: CodeType
if sys.version_info >= (3,):
__qualname__: str
__code__: CodeType
__annotations__: Dict[str, Any]
class list(MutableSequence[_T], Generic[_T]):
@@ -905,7 +925,7 @@ class list(MutableSequence[_T], Generic[_T]):
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[_T]: ...
def __str__(self) -> str: ...
def __hash__(self) -> int: ...
__hash__: None # type: ignore
@overload
def __getitem__(self, i: int) -> _T: ...
@overload
@@ -978,7 +998,10 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
def __setitem__(self, k: _KT, v: _VT) -> None: ...
def __delitem__(self, v: _KT) -> None: ...
def __iter__(self) -> Iterator[_KT]: ...
if sys.version_info >= (3, 8):
def __reversed__(self) -> Iterator[_KT]: ...
def __str__(self) -> str: ...
__hash__: None # type: ignore
class set(MutableSet[_T], Generic[_T]):
def __init__(self, iterable: Iterable[_T] = ...) -> None: ...
@@ -1015,6 +1038,7 @@ class set(MutableSet[_T], Generic[_T]):
def __lt__(self, s: AbstractSet[object]) -> bool: ...
def __ge__(self, s: AbstractSet[object]) -> bool: ...
def __gt__(self, s: AbstractSet[object]) -> bool: ...
__hash__: None # type: ignore
class frozenset(AbstractSet[_T], Generic[_T]):
def __init__(self, iterable: Iterable[_T] = ...) -> None: ...
@@ -1106,8 +1130,6 @@ if sys.version_info < (3,):
if sys.version_info >= (3,):
def ascii(__o: object) -> str: ...
class _SupportsIndex(Protocol):
def __index__(self) -> int: ...
def bin(__number: Union[int, _SupportsIndex]) -> str: ...
if sys.version_info >= (3, 7):
@@ -1124,7 +1146,7 @@ if sys.version_info >= (3, 6):
# See https://github.com/python/typeshed/pull/991#issuecomment-288160993
class _PathLike(Generic[AnyStr]):
def __fspath__(self) -> AnyStr: ...
def compile(source: Union[str, bytes, mod, AST], filename: Union[str, bytes, _PathLike], mode: str, flags: int = ..., dont_inherit: int = ..., optimize: int = ...) -> Any: ...
def compile(source: Union[str, bytes, mod, AST], filename: Union[str, bytes, _PathLike[Any]], mode: str, flags: int = ..., dont_inherit: int = ..., optimize: int = ...) -> Any: ...
elif sys.version_info >= (3,):
def compile(source: Union[str, bytes, mod, AST], filename: Union[str, bytes], mode: str, flags: int = ..., dont_inherit: int = ..., optimize: int = ...) -> Any: ...
else:
@@ -1149,20 +1171,15 @@ if sys.version_info >= (3,):
def filter(__function: Callable[[_T], Any], __iterable: Iterable[_T]) -> Iterator[_T]: ...
else:
@overload
def filter(__function: Callable[[AnyStr], Any], # type: ignore
__iterable: AnyStr) -> AnyStr: ...
def filter(__function: Callable[[AnyStr], Any], __iterable: AnyStr) -> AnyStr: ... # type: ignore
@overload
def filter(__function: None, # type: ignore
__iterable: Tuple[Optional[_T], ...]) -> Tuple[_T, ...]: ...
def filter(__function: None, __iterable: Tuple[Optional[_T], ...]) -> Tuple[_T, ...]: ... # type: ignore
@overload
def filter(__function: Callable[[_T], Any], # type: ignore
__iterable: Tuple[_T, ...]) -> Tuple[_T, ...]: ...
def filter(__function: Callable[[_T], Any], __iterable: Tuple[_T, ...]) -> Tuple[_T, ...]: ... # type: ignore
@overload
def filter(__function: None,
__iterable: Iterable[Optional[_T]]) -> List[_T]: ...
def filter(__function: None, __iterable: Iterable[Optional[_T]]) -> List[_T]: ...
@overload
def filter(__function: Callable[[_T], Any],
__iterable: Iterable[_T]) -> List[_T]: ...
def filter(__function: Callable[[_T], Any], __iterable: Iterable[_T]) -> List[_T]: ...
def format(__o: object, __format_spec: str = ...) -> str: ... # TODO unicode
def getattr(__o: Any, name: Text, __default: Any = ...) -> Any: ...
def globals() -> Dict[str, Any]: ...
@@ -1180,9 +1197,11 @@ else:
@overload
def iter(__iterable: Iterable[_T]) -> Iterator[_T]: ...
@overload
def iter(__function: Callable[[], _T], __sentinel: _T) -> Iterator[_T]: ...
def isinstance(__o: object, __t: Union[type, Tuple[Union[type, Tuple], ...]]) -> bool: ...
def issubclass(__cls: type, __classinfo: Union[type, Tuple[Union[type, Tuple], ...]]) -> bool: ...
def iter(__function: Callable[[], Optional[_T]], __sentinel: None) -> Iterator[_T]: ...
@overload
def iter(__function: Callable[[], _T], __sentinel: Any) -> Iterator[_T]: ...
def isinstance(__o: object, __t: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]) -> bool: ...
def issubclass(__cls: type, __classinfo: Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]) -> bool: ...
def len(__o: Sized) -> int: ...
if sys.version_info >= (3,):
def license() -> None: ...
@@ -1318,7 +1337,7 @@ def next(__i: Iterator[_T], default: _VT) -> Union[_T, _VT]: ...
def oct(__i: Union[int, _SupportsIndex]) -> str: ...
if sys.version_info >= (3, 6):
def open(file: Union[str, bytes, int, _PathLike], mode: str = ..., buffering: int = ..., encoding: Optional[str] = ...,
def open(file: Union[str, bytes, int, _PathLike[Any]], mode: str = ..., buffering: int = ..., encoding: Optional[str] = ...,
errors: Optional[str] = ..., newline: Optional[str] = ..., closefd: bool = ...,
opener: Optional[Callable[[str, int], int]] = ...) -> IO[Any]: ...
elif sys.version_info >= (3,):
@@ -1332,12 +1351,16 @@ def ord(__c: Union[Text, bytes]) -> int: ...
if sys.version_info >= (3,):
class _Writer(Protocol):
def write(self, __s: str) -> Any: ...
def print(*values: object, sep: Text = ..., end: Text = ..., file: Optional[_Writer] = ..., flush: bool = ...) -> None: ...
def print(
*values: object, sep: Optional[Text] = ..., end: Optional[Text] = ..., file: Optional[_Writer] = ..., flush: bool = ...
) -> None: ...
else:
class _Writer(Protocol):
def write(self, __s: Any) -> Any: ...
# This is only available after from __future__ import print_function.
def print(*values: object, sep: Text = ..., end: Text = ..., file: Optional[_Writer] = ...) -> None: ...
def print(*values: object, sep: Optional[Text] = ..., end: Optional[Text] = ..., file: Optional[_Writer] = ...) -> None: ...
@overload
def pow(__x: int, __y: int) -> Any: ... # The return type can be int or float, depending on y
@overload
@@ -1370,7 +1393,7 @@ if sys.version_info >= (3,):
@overload
def round(number: SupportsRound[_T]) -> int: ...
@overload
def round(number: SupportsRound[_T], ndigits: None) -> int: ... # type: ignore
def round(number: SupportsRound[_T], ndigits: None) -> int: ...
@overload
def round(number: SupportsRound[_T], ndigits: int) -> _T: ...
else:
@@ -1390,7 +1413,7 @@ if sys.version_info >= (3,):
else:
def sorted(__iterable: Iterable[_T], *,
cmp: Callable[[_T, _T], int] = ...,
key: Callable[[_T], Any] = ...,
key: Optional[Callable[[_T], Any]] = ...,
reverse: bool = ...) -> List[_T]: ...
@overload
def sum(__iterable: Iterable[_T]) -> Union[_T, int]: ...
@@ -1436,8 +1459,10 @@ else:
def zip(__iter1: Iterable[Any], __iter2: Iterable[Any], __iter3: Iterable[Any],
__iter4: Iterable[Any], __iter5: Iterable[Any], __iter6: Iterable[Any],
*iterables: Iterable[Any]) -> List[Tuple[Any, ...]]: ...
def __import__(name: Text, globals: Dict[str, Any] = ..., locals: Dict[str, Any] = ...,
fromlist: List[str] = ..., level: int = ...) -> Any: ...
def __import__(name: Text, globals: Optional[Mapping[str, Any]] = ...,
locals: Optional[Mapping[str, Any]] = ...,
fromlist: Sequence[str] = ...,
level: int = ...) -> Any: ...
# Actually the type of Ellipsis is <type 'ellipsis'>, but since it's
# not exposed anywhere under that name, we make it private here.
@@ -1467,6 +1492,8 @@ class BaseException(object):
__suppress_context__: bool
__traceback__: Optional[TracebackType]
def __init__(self, *args: object) -> None: ...
def __str__(self) -> str: ...
def __repr__(self) -> str: ...
if sys.version_info < (3,):
def __getitem__(self, i: int) -> Any: ...
def __getslice__(self, start: int, stop: int) -> Tuple[Any, ...]: ...
@@ -1508,9 +1535,10 @@ class AttributeError(_StandardError): ...
class BufferError(_StandardError): ...
class EOFError(_StandardError): ...
class ImportError(_StandardError):
if sys.version_info >= (3,):
name: str
path: str
if sys.version_info >= (3, 3):
def __init__(self, *args, name: Optional[str] = ..., path: Optional[str] = ...) -> None: ...
name: Optional[str]
path: Optional[str]
class LookupError(_StandardError): ...
class MemoryError(_StandardError): ...
class NameError(_StandardError): ...
@@ -1523,7 +1551,7 @@ class SyntaxError(_StandardError):
msg: str
lineno: int
offset: Optional[int]
text: str
text: Optional[str]
filename: str
class SystemError(_StandardError): ...
class TypeError(_StandardError): ...
@@ -1612,7 +1640,7 @@ if sys.version_info < (3,):
def next(self) -> str: ...
def read(self, n: int = ...) -> str: ...
def __enter__(self) -> BinaryIO: ...
def __exit__(self, t: Optional[type] = ..., exc: Optional[BaseException] = ..., tb: Optional[Any] = ...) -> bool: ...
def __exit__(self, t: Optional[type] = ..., exc: Optional[BaseException] = ..., tb: Optional[Any] = ...) -> Optional[bool]: ...
def flush(self) -> None: ...
def fileno(self) -> int: ...
def isatty(self) -> bool: ...
+4 -1
View File
@@ -5,7 +5,7 @@ from typing import Any, Callable, Dict, Optional, Text, TypeVar, Union
def run(statement: str, filename: Optional[str] = ..., sort: Union[str, int] = ...) -> None: ...
def runctx(statement: str, globals: Dict[str, Any], locals: Dict[str, Any], filename: Optional[str] = ..., sort: Union[str, int] = ...) -> None: ...
_SelfT = TypeVar('_SelfT', bound='Profile')
_SelfT = TypeVar('_SelfT', bound=Profile)
_T = TypeVar('_T')
if sys.version_info >= (3, 6):
_Path = Union[bytes, Text, os.PathLike[Any]]
@@ -22,3 +22,6 @@ class Profile:
def run(self: _SelfT, cmd: str) -> _SelfT: ...
def runctx(self: _SelfT, cmd: str, globals: Dict[str, Any], locals: Dict[str, Any]) -> _SelfT: ...
def runcall(self, func: Callable[..., _T], *args: Any, **kw: Any) -> _T: ...
if sys.version_info >= (3, 8):
def __enter__(self: _SelfT) -> _SelfT: ...
def __exit__(self, *exc_info: Any) -> None: ...
+7 -7
View File
@@ -5,8 +5,9 @@ _T = TypeVar('_T', bound=FieldStorage)
def parse(fp: IO[Any] = ..., environ: Mapping[str, str] = ...,
keep_blank_values: bool = ..., strict_parsing: bool = ...) -> Dict[str, List[str]]: ...
def parse_qs(qs: str, keep_blank_values: bool = ..., strict_parsing: bool = ...) -> Dict[str, List[str]]: ...
def parse_qsl(qs: str, keep_blank_values: bool = ..., strict_parsing: bool = ...) -> Dict[str, List[str]]: ...
if sys.version_info < (3, 8):
def parse_qs(qs: str, keep_blank_values: bool = ..., strict_parsing: bool = ...) -> Dict[str, List[str]]: ...
def parse_qsl(qs: str, keep_blank_values: bool = ..., strict_parsing: bool = ...) -> Dict[str, List[str]]: ...
if sys.version_info >= (3, 7):
def parse_multipart(fp: IO[Any], pdict: Mapping[str, bytes], encoding: str = ..., errors: str = ...) -> Dict[str, List[Any]]: ...
else:
@@ -17,11 +18,10 @@ def print_environ(environ: Mapping[str, str] = ...) -> None: ...
def print_form(form: Dict[str, Any]) -> None: ...
def print_directory() -> None: ...
def print_environ_usage() -> None: ...
if sys.version_info >= (3, 0):
def escape(s: str, quote: bool = ...) -> str: ...
else:
if sys.version_info < (3,):
def escape(s: AnyStr, quote: bool = ...) -> AnyStr: ...
elif sys.version_info < (3, 8):
def escape(s: str, quote: bool = ...) -> str: ...
class MiniFieldStorage:
# The first five "Any" attributes here are always None, but mypy doesn't support that
@@ -101,7 +101,7 @@ class FieldStorage(object):
if sys.version_info < (3, 0):
from UserDict import UserDict
class FormContentDict(UserDict):
class FormContentDict(UserDict[str, List[str]]):
query_string: str
def __init__(self, environ: Mapping[str, str] = ..., keep_blank_values: int = ..., strict_parsing: int = ...) -> None: ...
+33
View File
@@ -0,0 +1,33 @@
from typing import Dict, Any, List, Tuple, Optional, Callable, Type, Union, IO, AnyStr, TypeVar
from types import FrameType, TracebackType
import sys
_T = TypeVar("_T")
_ExcInfo = Tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]]
if sys.version_info >= (3, 6):
from os import PathLike
_Path = Union[_T, PathLike[_T]]
else:
_Path = Union[_T]
def reset() -> str: ... # undocumented
def small(text: str) -> str: ... # undocumented
def strong(text: str) -> str: ... # undocumented
def grey(text: str) -> str: ... # undocumented
def lookup(name: str, frame: FrameType, locals: Dict[str, Any]) -> Tuple[Optional[str], Any]: ... # undocumented
def scanvars(reader: Callable[[], bytes], frame: FrameType, locals: Dict[str, Any]) -> List[Tuple[str, Optional[str], Any]]: ... # undocumented
def html(einfo: _ExcInfo, context: int = ...) -> str: ...
def text(einfo: _ExcInfo, context: int = ...) -> str: ...
class Hook: # undocumented
def __init__(self, display: int = ..., logdir: Optional[_Path[AnyStr]] = ..., context: int = ..., file: Optional[IO[str]] = ..., format: str = ...) -> None: ...
def __call__(self, etype: Optional[Type[BaseException]], evalue: Optional[BaseException], etb: Optional[TracebackType]) -> None: ...
def handle(self, info: Optional[_ExcInfo] = ...) -> None: ...
def handler(info: Optional[_ExcInfo] = ...) -> None: ...
def enable(display: int = ..., logdir: Optional[_Path[AnyStr]] = ..., context: int = ..., format: str = ...) -> None: ...
+5 -3
View File
@@ -31,6 +31,8 @@ class _IncrementalDecoder(Protocol):
def encode(obj: _Decoded, encoding: str = ..., errors: str = ...) -> _Encoded: ...
def decode(obj: _Encoded, encoding: str = ..., errors: str = ...) -> _Decoded: ...
def lookup(encoding: str) -> CodecInfo: ...
def utf_16_be_decode(__obj: _Encoded, __errors: str = ..., __final: bool = ...) -> Tuple[_Decoded, int]: ... # undocumented
def utf_16_be_encode(__obj: _Decoded, __errors: str = ...) -> Tuple[_Encoded, int]: ... # undocumented
class CodecInfo(Tuple[_Encoder, _Decoder, _StreamReader, _StreamWriter]):
@property
@@ -63,7 +65,7 @@ def getincrementalencoder(encoding: str) -> _IncrementalEncoder: ...
def getincrementaldecoder(encoding: str) -> _IncrementalDecoder: ...
def getreader(encoding: str) -> _StreamReader: ...
def getwriter(encoding: str) -> _StreamWriter: ...
def register(search_function: Callable[[str], CodecInfo]) -> None: ...
def register(search_function: Callable[[str], Optional[CodecInfo]]) -> None: ...
def open(filename: str, mode: str = ..., encoding: str = ..., errors: str = ..., buffering: int = ...) -> StreamReaderWriter: ...
def EncodedFile(file: IO[_Encoded], data_encoding: str, file_encoding: str = ..., errors: str = ...) -> StreamRecoder: ...
def iterencode(iterator: Iterable[_Decoded], encoding: str, errors: str = ...) -> Generator[_Encoded, None, None]: ...
@@ -186,7 +188,7 @@ class StreamReaderWriter(TextIO):
def __enter__(self: _T) -> _T: ...
def __exit__(
self, typ: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[types.TracebackType]
) -> bool: ...
) -> None: ...
def __getattr__(self, name: str) -> Any: ...
# These methods don't actually exist directly, but they are needed to satisfy the TextIO
# interface. At runtime, they are delegated through __getattr__.
@@ -227,7 +229,7 @@ class StreamRecoder(BinaryIO):
def __enter__(self: _SRT) -> _SRT: ...
def __exit__(
self, type: Optional[Type[BaseException]], value: Optional[BaseException], tb: Optional[types.TracebackType]
) -> bool: ...
) -> None: ...
# These methods don't actually exist directly, but they are needed to satisfy the BinaryIO
# interface. At runtime, they are delegated through __getattr__.
def seek(self, offset: int, whence: int = ...) -> int: ...
+21 -9
View File
@@ -18,17 +18,20 @@ if sys.version_info >= (3, 7):
from typing import AsyncContextManager as AbstractAsyncContextManager
_T = TypeVar('_T')
_F = TypeVar('_F', bound=Callable[..., Any])
_ExitFunc = Callable[[Optional[Type[BaseException]],
Optional[BaseException],
Optional[TracebackType]], bool]
_CM_EF = TypeVar('_CM_EF', ContextManager, _ExitFunc)
_CM_EF = TypeVar('_CM_EF', ContextManager[Any], _ExitFunc)
if sys.version_info >= (3, 2):
class GeneratorContextManager(ContextManager[_T], Generic[_T]):
def __call__(self, func: Callable[..., _T]) -> Callable[..., _T]: ...
def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., GeneratorContextManager[_T]]: ...
class _GeneratorContextManager(ContextManager[_T], Generic[_T]):
def __call__(self, func: _F) -> _F: ...
def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., _GeneratorContextManager[_T]]: ...
else:
class GeneratorContextManager(ContextManager[_T], Generic[_T]):
def __call__(self, func: _F) -> _F: ...
def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., ContextManager[_T]]: ...
if sys.version_info >= (3, 7):
@@ -43,19 +46,22 @@ class closing(ContextManager[_T], Generic[_T]):
if sys.version_info >= (3, 4):
class suppress(ContextManager[None]):
def __init__(self, *exceptions: Type[BaseException]) -> None: ...
def __exit__(self, exctype: Optional[Type[BaseException]],
excinst: Optional[BaseException],
exctb: Optional[TracebackType]) -> bool: ...
class redirect_stdout(ContextManager[None]):
def __init__(self, new_target: IO[str]) -> None: ...
def __init__(self, new_target: Optional[IO[str]]) -> None: ...
if sys.version_info >= (3, 5):
class redirect_stderr(ContextManager[None]):
def __init__(self, new_target: IO[str]) -> None: ...
def __init__(self, new_target: Optional[IO[str]]) -> None: ...
if sys.version_info >= (3,):
class ContextDecorator:
def __call__(self, func: Callable[..., None]) -> Callable[..., ContextManager[None]]: ...
_U = TypeVar('_U', bound='ExitStack')
_U = TypeVar('_U', bound=ExitStack)
class ExitStack(ContextManager[ExitStack]):
def __init__(self) -> None: ...
@@ -66,17 +72,20 @@ if sys.version_info >= (3,):
def pop_all(self: _U) -> _U: ...
def close(self) -> None: ...
def __enter__(self: _U) -> _U: ...
def __exit__(self, __exc_type: Optional[Type[BaseException]],
__exc_value: Optional[BaseException],
__traceback: Optional[TracebackType]) -> bool: ...
if sys.version_info >= (3, 7):
from typing import Awaitable
_S = TypeVar('_S', bound='AsyncExitStack')
_S = TypeVar('_S', bound=AsyncExitStack)
_ExitCoroFunc = Callable[[Optional[Type[BaseException]],
Optional[BaseException],
Optional[TracebackType]], Awaitable[bool]]
_CallbackCoroFunc = Callable[..., Awaitable[Any]]
_ACM_EF = TypeVar('_ACM_EF', AsyncContextManager, _ExitCoroFunc)
_ACM_EF = TypeVar('_ACM_EF', AsyncContextManager[Any], _ExitCoroFunc)
class AsyncExitStack(AsyncContextManager[AsyncExitStack]):
def __init__(self) -> None: ...
@@ -91,6 +100,9 @@ if sys.version_info >= (3, 7):
def pop_all(self: _S) -> _S: ...
def aclose(self) -> Awaitable[None]: ...
def __aenter__(self: _S) -> Awaitable[_S]: ...
def __aexit__(self, __exc_type: Optional[Type[BaseException]],
__exc_value: Optional[BaseException],
__traceback: Optional[TracebackType]) -> Awaitable[bool]: ...
if sys.version_info >= (3, 7):
@overload
+1 -2
View File
@@ -1,6 +1,5 @@
import sys
from typing import List, NamedTuple, Optional, Union
from typing import List, Optional, Union
if sys.version_info >= (3, 3):
class _Method: ...
+40 -28
View File
@@ -1,24 +1,24 @@
from collections import OrderedDict
import sys
from typing import Any, Dict, Iterable, Iterator, List, Mapping, Optional, Sequence, Union
from _csv import (
QUOTE_ALL as QUOTE_ALL,
QUOTE_MINIMAL as QUOTE_MINIMAL,
QUOTE_NONE as QUOTE_NONE,
QUOTE_NONNUMERIC as QUOTE_NONNUMERIC,
Error as Error,
_reader,
_writer,
field_size_limit as field_size_limit,
get_dialect as get_dialect,
list_dialects as list_dialects,
reader as reader,
register_dialect as register_dialect,
unregister_dialect as unregister_dialect,
writer as writer,
)
from collections import OrderedDict
from typing import Any, Dict, Iterable, Iterator, List, Mapping, Optional, Sequence, Text, Type, Union
from _csv import (_reader,
_writer,
reader as reader,
writer as writer,
register_dialect as register_dialect,
unregister_dialect as unregister_dialect,
get_dialect as get_dialect,
list_dialects as list_dialects,
field_size_limit as field_size_limit,
QUOTE_ALL as QUOTE_ALL,
QUOTE_MINIMAL as QUOTE_MINIMAL,
QUOTE_NONE as QUOTE_NONE,
QUOTE_NONNUMERIC as QUOTE_NONNUMERIC,
Error as Error,
)
_Dialect = Union[str, Dialect]
_Dialect = Union[str, Dialect, Type[Dialect]]
_DictRow = Mapping[str, Any]
class Dialect(object):
@@ -56,7 +56,6 @@ if sys.version_info >= (3, 6):
else:
_DRMapping = Dict[str, str]
class DictReader(Iterator[_DRMapping]):
restkey: Optional[str]
restval: Optional[str]
@@ -64,24 +63,37 @@ class DictReader(Iterator[_DRMapping]):
dialect: _Dialect
line_num: int
fieldnames: Sequence[str]
def __init__(self, f: Iterable[str], fieldnames: Sequence[str] = ...,
restkey: Optional[str] = ..., restval: Optional[str] = ..., dialect: _Dialect = ...,
*args: Any, **kwds: Any) -> None: ...
def __init__(
self,
f: Iterable[Text],
fieldnames: Optional[Sequence[str]] = ...,
restkey: Optional[str] = ...,
restval: Optional[str] = ...,
dialect: _Dialect = ...,
*args: Any,
**kwds: Any,
) -> None: ...
def __iter__(self) -> DictReader: ...
if sys.version_info >= (3,):
def __next__(self) -> _DRMapping: ...
else:
def next(self) -> _DRMapping: ...
class DictWriter(object):
fieldnames: Sequence[str]
restval: Optional[Any]
extrasaction: str
writer: _writer
def __init__(self, f: Any, fieldnames: Sequence[str],
restval: Optional[Any] = ..., extrasaction: str = ..., dialect: _Dialect = ...,
*args: Any, **kwds: Any) -> None: ...
def __init__(
self,
f: Any,
fieldnames: Iterable[str],
restval: Optional[Any] = ...,
extrasaction: str = ...,
dialect: _Dialect = ...,
*args: Any,
**kwds: Any,
) -> None: ...
def writeheader(self) -> None: ...
def writerow(self, rowdict: _DictRow) -> None: ...
def writerows(self, rowdicts: Iterable[_DictRow]) -> None: ...
@@ -89,5 +101,5 @@ class DictWriter(object):
class Sniffer(object):
preferred: List[str]
def __init__(self) -> None: ...
def sniff(self, sample: str, delimiters: Optional[str] = ...) -> Dialect: ...
def sniff(self, sample: str, delimiters: Optional[str] = ...) -> Type[Dialect]: ...
def has_header(self, sample: str) -> bool: ...
+10 -3
View File
@@ -24,8 +24,15 @@ class CDLL(object):
_name: str = ...
_handle: int = ...
_FuncPtr: Type[_FuncPointer] = ...
def __init__(self, name: str, mode: int = ..., handle: Optional[int] = ...,
use_errno: bool = ..., use_last_error: bool = ...) -> None: ...
def __init__(
self,
name: str,
mode: int = ...,
handle: Optional[int] = ...,
use_errno: bool = ...,
use_last_error: bool = ...,
winmode: Optional[int] = ...,
) -> None: ...
def __getattr__(self, name: str) -> _FuncPointer: ...
def __getitem__(self, name: str) -> _FuncPointer: ...
if sys.platform == 'win32':
@@ -228,7 +235,7 @@ class c_wchar_p(_PointerLike, _SimpleCData[Optional[Text]]):
def __init__(self, value: Optional[_UnionT[int, Text]] = ...) -> None: ...
class c_bool(_SimpleCData[bool]):
def __init__(self, value: bool) -> None: ...
def __init__(self, value: bool = ...) -> None: ...
if sys.platform == 'win32':
class HRESULT(_SimpleCData[int]): ... # TODO undocumented
+15
View File
@@ -0,0 +1,15 @@
from _curses import * # noqa: F403
from _curses import _CursesWindow as _CursesWindow
from typing import TypeVar, Callable, Any
_T = TypeVar('_T')
# available after calling `curses.initscr()`
LINES: int
COLS: int
# available after calling `curses.start_color()`
COLORS: int
COLOR_PAIRS: int
def wrapper(func: Callable[..., _T], *arg: Any, **kwds: Any) -> _T: ...

Some files were not shown because too many files have changed in this diff Show More