Commit Graph

2717 Commits

Author SHA1 Message Date
Sebastian Rittau
36356b3368 Remove argument from deque.pop() (#4367)
Closes: #4364
2020-07-27 06:49:56 -07:00
Sebastian Rittau
06f87e5c92 Simplify pathlib (#4357)
* Enable some branches for Python2 pathlib2
* Define an alias _PathLike, instead of using multiple branches
* Drop a Python 3.4 branch (the Python 2 branch is identical to
  the 3.5+ branch)
* Move Path.__new__ to the top
2020-07-27 06:08:09 -07:00
karl ding
8f50cd9d0e Add missing syslog facility codes (#4366)
Add support for the following syslog facilities:

  - LOG_NTP
  - LOG_SECURITY
  - LOG_CONSOLE
  - LOG_SOLCRON

In addition, reorder the entries to match the CPython implementation to
make it easier to read.
2020-07-27 12:34:12 +02:00
Ian Good
a472c9b543 Fix Policy.header_source_parse return type (#4365) 2020-07-27 08:38:40 +02:00
Akuli
2c37551fd1 make tkinter.Event generic and add missing type hints to bind methods (#4347) 2020-07-25 14:23:26 +02:00
Vegard Stikbakke
51fd8b2a06 Fix Filter.filter return type - bool, not int (#4358) 2020-07-24 20:25:06 +02:00
Akuli
9efc9d8818 add tkinter.font stub (#4350) 2020-07-22 11:46:04 -07:00
Peter Law
29dec525e7 Add pydoc_data (#4351)
This appears to be used by jedi at least, so it would be great to
have stubs for it.
2020-07-21 18:14:03 -07:00
Shantanu
bc6da51495 asyncio: export submodules (#4346)
Resolves #4345

Co-authored-by: hauntsaninja <>
2020-07-21 09:34:00 +02:00
Philipp Hahn
e44ac21d98 optparse: option_class is Type[Option] (#4338)
It's a `class`, not an `instance`.

<https://docs.python.org/2.7/library/optparse.html#optparse.OptionParser>
2020-07-17 20:50:02 +02:00
Shantanu
d998d37954 multiprocessing: revert changes to queue classes (#4314)
Partial revert of #4289. Fixes #4313
2020-07-16 15:03:25 -07:00
Sebastian Rittau
5e76f51930 Upgrade to isort 5 (#4323)
This now also reformats imports not at the top of files.
2020-07-16 07:01:57 -07:00
Shantanu
5ecdc08bb1 tarfile: fix arg name (#4326)
And update whitelist since #4322 fixed a thing

Co-authored-by: hauntsaninja <>
2020-07-12 20:27:43 +02:00
Sebastian Rittau
9ad8ed3b75 Introduce Mapping-like protocols (#4325)
typing.Mapping is not a protocol, which has caused problems in the past.
(E.g. python/typeshed#3569, see also python/typeshed#3576.) This
introduces a few narrow protocols to _typeshed.pyi that can be used in
place of Mapping.

Not all uses of Mapping can be replaced. For example, cgi.FieldStorage
explictly checks whether the supplied headers argument is a Mapping
instance.
2020-07-11 17:11:08 -07:00
Jonathan Slenders
028f0d5293 Fix: TarFile.tarinfo is a Type instead of instance. (#4322)
Co-authored-by: Jonathan Slenders <jslender@cisco.com>
2020-07-10 12:22:04 +02:00
Alex Grönholm
ad89dee03b Fixed return type of getaddrinfo() everywhere (#4304) 2020-07-10 10:46:28 +02:00
Joshua Oreman
e6736cde8d ctypes: allow cast() 1st argument to be int and 2nd argument to be Type[py_object] (#4311) 2020-07-10 10:44:23 +02:00
Alex Grönholm
f9d469ac2b Fixed parameter and return types of getnameinfo() everywhere (#4305) 2020-07-03 15:46:02 +02:00
Steve B
c0e9c4f4c5 add overloads for combinations r 2-5 (#4309)
This doesn't cover everything but it means it a lot of common usages the type will be slightly more useful

Co-authored-by: steve brazier <steve.brazier@trioptima.com>
2020-07-03 15:23:43 +02:00
Sebastian Rittau
b8f6d5fc54 Replace a few instances of IO with protocols (#4296) 2020-06-30 18:05:30 -07:00
wouter bolsterlee
83e955b52f Use correct return type annotation for BaseException.with_traceback (#4298)
The return type of the BaseException.with_traceback() method [1] is not
specific enough. The return type is guaranteed to be of the same type as
‘self’, which is usually a subclass of BaseException.

In fact, .with_traceback() returns ‘self’:

    try:
        raise ValueError
    except Exception as exc:
        assert exc.with_traceback(None) is exc

Fix the annotation to reflect this using the self-type annotation
technique described in PEP484 [2], which is supported by (at least)
mypy [3].

[1] https://docs.python.org/3/library/exceptions.html#BaseException.with_traceback
[2] https://www.python.org/dev/peps/pep-0484/#annotating-instance-and-class-methods
[3] https://github.com/python/mypy/issues/1212
2020-06-30 11:40:25 -07:00
Artem Simonov
f0269cd438 fix shutil.chown type annotations (#4294)
According to the official docs, "user can be a system user name or a uid;
the same applies to group".

Co-authored-by: Artem Simonov <artem.simonov@dejero.com>
2020-06-30 09:39:38 +02:00
Jelle Zijlstra
0142a87da8 adjust isort config (#4290)
Fixes #4288.

- Default imports to THIRD_PARTY, so in effect we merge the FIRST_PARTY and THIRD_PARTY stubs. This means import order is no longer affected by whether typing_extensions is installed locally.
- Treat typing_extensions, _typeshed and some others as standard library modules.

Note that isort master is very different from the latest release; we'll have to do something
different if and when the next isort release comes out.
2020-06-29 00:00:21 -07:00
Vishal Kuo
cc8344b8c6 [multiprocessing] fixes more incorrect types (#4289) 2020-06-28 16:08:14 -07:00
Sebastian Rittau
4586ed9adc Require black and isort for contributions (#3329)
* Add explanation to CONTRIBUTNG.md
* Add sample pre-commit script
* Check for correctly formatted files in CI

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2020-06-28 15:28:28 -07:00
Jelle Zijlstra
5d553c9584 apply black and isort (#4287)
* apply black and isort

* move some type ignores
2020-06-28 13:31:00 -07:00
Shantanu
fe58699ca5 collections/typing: fix various arg names (#4258)
This feels nervous, but if it passes unit tests it's unlikely to break
anything
2020-06-28 12:27:21 -07:00
Denis Laxalde
0dd3258ed2 Add __aiter__ and __anext__ methods for asyncio.StreamReader (#4286)
The following code produces an error in mypy:

    import asyncio
    from asyncio.subprocess import PIPE

    async def main() -> None:
        proc = await asyncio.create_subprocess_shell("ls -l", stdout=PIPE)
        assert proc.stdout is not None
        async for line in proc.stdout:
            print(line.decode())
        await proc.wait()

    asyncio.run(main())

$ mypy --strict file.py
file.py:8: error: "StreamReader" has no attribute "__aiter__" (not async iterable)

This commits fixes this by adding __aiter__/__anext__ methods that are
needed for async iterator protocol.
2020-06-28 11:57:49 -07:00
Peter Law
ed04d33def Make redirect_std{out,err} yield new stream as context var (#4285)
This matches the implementation, even though this behaviour isn't
actually documented yet. https://bugs.python.org/issue41147 aims
to fix the documentation issue though.

Fixes https://github.com/python/typeshed/issues/4283.
2020-06-28 07:36:09 -07:00
Vishal Kuo
e467fd50ab multiprocessing: add sharedctypes, fix some stubtest cases (#4282) 2020-06-26 23:38:34 -07:00
Sebastian Rittau
564a8220f4 Add float.__ceil__ and __floor__ (#4274)
Closes: #3195
2020-06-26 22:26:39 -07:00
Shantanu
64327e02e9 keyword: update for py39 (#4272) 2020-06-26 20:50:16 +02:00
Shantanu
afcb46655a graphlib: add in py39 (#4268)
Co-authored-by: hauntsaninja <>
2020-06-26 20:49:50 +02:00
Shantanu
9a16b02187 argparse: fix for latest py39 (#4267)
https://github.com/python/typeshed/pull/4144 and
https://github.com/python/cpython/pull/11478#pullrequestreview-423968410
resulted in the issue being fixed upstream.


Co-authored-by: hauntsaninja <>
2020-06-26 12:55:23 +02:00
Shantanu
cc150f1d76 compileall: update for py39 again (#4269)
Co-authored-by: hauntsaninja <>
2020-06-26 12:46:18 +02:00
Shantanu
fc8b0ed94e builtins: remove __class_getitem__ from type (#4270)
Co-authored-by: hauntsaninja <>
2020-06-26 12:45:22 +02:00
Shantanu
2ba6939788 imaplib: update for py39 (#4271) 2020-06-26 12:40:27 +02:00
Shantanu
1c3f526fbf pickle: improve positional-arg accuracy in py39 and others (#4273)
Although technically data in loads is not positional-only in py38, but
we decided that that doesn't matter

Co-authored-by: hauntsaninja <>
2020-06-26 12:29:47 +02:00
Jia Chen
92fa4e799c Using dunder parameter name in builtins._SupportsLessThan (#4264) 2020-06-25 21:02:00 +02:00
Shantanu
70459abb44 Revert "zip: add some overloads for heterogeneous tuples (#3830)" (#4254)
This reverts commit e857ad6ba9.

Co-authored-by: hauntsaninja <>
2020-06-25 08:46:02 -07:00
helafumpek
534ebd5051 Change argument type in random.shuffle (python/typeshed#4255) (#4260)
Fixes #4255
2020-06-24 08:17:13 +02:00
Milap Sheth
14af8790f3 Added missing properties to struct_time (#4256) 2020-06-22 20:43:53 -07:00
Bruce Merry
fb398b1d59 Use the ReadableBuffer type in more places (#4245)
This is a follow-up on #4232. memoryview, hashlib, and hmac are updated
to use ReadableBuffer type instead of their own home-spun unions of
bytes, bytearray and whatever else each use case used. mmap is being
handled in #4244, and I'll leave BinaryIO for another day (or possibly
another person) because it's going to require some messy code
duplication because the relevant methods are defined in IO[AnyStr].

There's one corner case I'm not quite sure how best to handle: the
documentation for hmac.digest claim that the parmaeters have the same
meanings as in hmac.new, but in CPython the latter has an explicit check
that `key` is bytes or bytearray while the former works with a
memory-view. For now I've matched the documentation.

Also, the documentation for HMAC.update says that `msg` can be any type
supported by hashlib from Python 3.4; but I can't see anything in the
Python 2.7 implementation that would prevent it also taking bytes-like
objects, so I've not tried to treat Python 2 any different to Python 3.
2020-06-22 06:17:24 -07:00
Jelle Zijlstra
e1d89e5742 remove references to "Text" in Python 3-only stubs (#4251) 2020-06-22 12:39:01 +02:00
Milap Sheth
66a9a4b5ce Fix type hint of generator throw method (#4253)
* Fix type hint of generator throw method

* Incorporated changes from #4252
2020-06-21 15:23:28 -07:00
Milap Sheth
9b3edda33b Fix unittest stub issues reported by mypy stubtest (#4248)
Co-authored-by: Shantanu <>
2020-06-21 15:09:17 -07:00
Rune Tynan
79111ee8ed Fix _DispatchProtocol in xmlrpc.server (#4165) 2020-06-21 13:42:14 -07:00
Russell Davis
aca6bd7e88 Fix os.exec* and os.spawn* to allow PathLike for all args (#4236) 2020-06-21 13:41:19 -07:00
Bruce Merry
ec6116dfa4 Update mmap stubs for newer Python versions (#4244)
* Update mmap stubs for newer Python versions

Based on the Python stdlib documentation:
- Since Python 3.5, mmap.{find,rfind,write} all accept any bytes-like.
  I've used the _typeshed.ReadableBuffer alias defined in #4232.
- Since Python 3.6, mmap.write returns the number of bytes written.
- Since Python 3.3, mmap.read allows None as the parameter; while in
  Python 2 the argument cannot be omitted.

* Further clean up mmap.pyi

Use the fact that Python 3.0-3.4 are no longer supported to clean up the
version-dependent logic. Functions that always have different signatures
in Python 2/3 are moved from the base _mmap[bytes] to the mmap subclass.
2020-06-21 13:37:19 -07:00
Milap Sheth
671d6eb804 Update operator stubs to support slices for getitem/setitem/delitem (#4250) 2020-06-20 16:41:46 -07:00