Commit Graph

3303 Commits

Author SHA1 Message Date
Anton Grübel
1e39a5899a refactor enum type hints in ssl (#5806) 2021-07-29 20:41:45 -07:00
Bas van Beek
7c37d6117d Allow reversed to take any object implementing __len__ and __getitem__ (#5820)
`reversed` is currently annotated as accepting either a `Sequence` or objects implementing the `__reversed__` protocol.
This however is too strict as, per its [docs](https://docs.python.org/3/library/functions.html#reversed), it can take any object that implements `__len__` and `__getitem__`.
2021-07-29 07:48:14 -07:00
MapleCCC
65b3a4b09d Add type annotation for multiprocessing.SimpleQueue.close() method (#5814) 2021-07-28 09:43:27 -07:00
Sebastian Rittau
2410c4f751 Add missing items for distutils.command.* (#5773)
This was mostly generated by running stubgen. Existing annotations were
kept, but converted to use PEP 604 and PEP 585.
2021-07-24 14:04:17 -07:00
Anton Grübel
7c5d76aca0 add missing protocol version 5 in pickle (#5801) 2021-07-24 13:42:11 -07:00
Oleg Höfling
a6a744a9d0 Add type hint for linecache.cache dict (#5805) 2021-07-24 14:59:33 +02:00
an onion
c4faf466b3 Add type stubs for xml.dom.pulldom (#5803)
Co-authored-by: Stephanie Ding <sym@fb.com>
2021-07-24 14:53:03 +02:00
Anton Grübel
af9b46a9a1 add missing type hints in http.cookiejar (#5797)
Co-authored-by: Akuli <akuviljanen17@gmail.com>
2021-07-22 16:21:36 +03:00
Anton Grübel
966858fd4c add missing type hints in zipfile (#5795) 2021-07-20 18:23:19 +02:00
Anton Grübel
9f34ccd864 Add missing type hints in http.server (#5785) 2021-07-19 23:31:06 +02:00
Sebastian Rittau
3bb397055c Improve distutils and lib2to3 (#5763)
Add missing elements to distutils.util:

* run_2to3()
* copydir_run_2to3()
* Mixin2to3

Use PEP 604 and PEP 585.

Add lib2to3.refactor.
2021-07-12 20:15:54 +02:00
Bas van Beek
5e23e2c19a Use SupportsIndex where applicable in builtins.pyi (#5739)
* Use `SupportsIndex` where applicable in `builtins.pyi`

* Remove `None` from the `int.__round__` ndigits parameter
2021-07-09 13:08:19 +03:00
Nsukami _
0330530de0 Update pwd stub file (#5741)
Add the following properties to struct_passwd:
* n_fields
* n_sequence_fields
* n_unnamed_fields

Co-authored-by: Akuli <akuviljanen17@gmail.com>
2021-07-09 12:54:22 +03:00
Thomas Grainger
c968614bae fix type of FileIO.__init__ opener kwarg (#5738)
Co-authored-by: Akuli <akuviljanen17@gmail.com>
2021-07-08 13:50:56 -07:00
Anton Grübel
0085539df3 Add missing type hints in http.client (#5734)
* Add missing type hints in http.client

* Add http.client.HTTPConnection.response_class to exclude list
2021-07-08 14:43:42 +03:00
Akuli
42247feefb use Self in async context managers (#5724) 2021-07-06 08:47:49 +02:00
Unrud
2ee7b1346b Replace IO[str] with IO[bytes] in urllib.request (#5728) 2021-07-05 09:41:59 +02:00
Josh
2b497f7227 importlib.util.resolve_name package argument accepts None (#5730) 2021-07-05 09:21:40 +02:00
Anton Grübel
d68701c0ec Use _typeshed.Self with __enter__ (#5723)
Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
Co-authored-by: Akuli <akuviljanen17@gmail.com>
2021-07-04 21:10:01 +03:00
Fabian Raab
1a131a489e [UserList]: Return type for slice is set to whatever self is (#5722) 2021-07-02 21:20:17 +02:00
Anton Grübel
de19554dcc Add json.py_encode_basestring stubs (#5720) 2021-07-02 11:18:35 +03:00
Anton Grübel
8a107464a8 Use _typeshed.Self with __enter__ (#5719) 2021-07-01 23:15:13 +02:00
Anton Grübel
96e0660fba Use _typeshed.Self with __enter__ (#5717)
Co-authored-by: Akuli <akuviljanen17@gmail.com>
2021-07-01 12:32:32 +02:00
Shantanu
04f0113d16 dataclasses: work around default factory issues (#5718) 2021-07-01 08:07:00 +02:00
Luis Marsano
c6b78354e6 stdlib logging: specify style type as literal choice (#5716)
documented for style parameter: https://docs.python.org/3/library/logging.html#logging.Formatter
2021-06-30 14:50:21 -07:00
Akuli
b06352556d Use Literal["little", "big"] for byteorder (#5715) 2021-06-30 13:15:50 -07:00
kasium
2c97c3cab9 Flag LogRecord.args as optional (#5714)
Resolves #5710
2021-06-30 14:51:32 +02:00
Anton Grübel
c38171a0b3 Use _typeshed.Self with __enter__ (#5712) 2021-06-29 15:19:25 -07:00
Anton Grübel
35cc7491db Add __defaults__ and __closure__ to types.MethodType (#5707) 2021-06-29 10:21:06 -07:00
Thomas Grainger
bd50dacd76 add py3.10 async contextlib.nullcontext (#5711) 2021-06-29 08:35:44 -07:00
Charly C
389b92cb04 fix the stub files for the stdlib mmap module (#5705)
In Python 3:
- The `mmap` type is `Iterable[int]`, not `Iterable[bytes]`.
- The `read_byte` method returns an `int`, and the `write_byte` method only accepts an `int` as its first and only argument.
- The `__setitem__` method accepts any `ReadableBuffer` object, not just `bytes`.

In both Python 2 and 3:
- The `__delitem__` method always raises a `TypeError`, so the proper return type is `NoReturn`.
- The `mmap` type isn't generic, so I've simplified the stubs by removing the unnecessary `_mmap` class.
2021-06-29 08:01:32 -07:00
Thomas Grainger
14add7520b widen _SupportsAclose (#5708)
see https://github.com/python-trio/trio-typing/issues/31#issuecomment-867534826
2021-06-28 15:29:21 -07:00
Dominic Davis-Foster
58559e56b3 Use _typeshed.Self where __enter__ returns self (#5698) 2021-06-27 22:58:58 +03:00
Bas van Beek
50f5858a56 Use SupportsIndex where applicable for 5 classes (#5694)
Use `SupportsIndex` where applicable:

* `str`
* `bytes`
* `bytearray`
* `memoryview`
* `markupsafe.Markup`
2021-06-26 19:05:40 +03:00
Thomas Grainger
c522e8e53c contextlib.nullcontext is a class (#5695)
Co-authored-by: Akuli <akuviljanen17@gmail.com>
2021-06-26 08:19:03 -07:00
Jelle Zijlstra
5fe2459779 Make SigParameter.replace and Signature.replace return Self (#5689) 2021-06-24 18:01:58 +02:00
Thomas Grainger
2cd7e6511b fix abcmeta.ABCMeta type (#5688)
Add __abstractmethods__, __instancecheck__ and __subclasscheck__

Co-authored-by: Akuli <akuviljanen17@gmail.com>
2021-06-24 16:56:09 +03:00
Sebastian Rittau
dd441645ad Make logging.StreamHandler generic over stream (#5681)
Closes #5680
2021-06-23 17:03:18 +03:00
Sebastian Rittau
816a92b8e8 Add Self type var to _typeshed (#5677)
Cf. #5676
2021-06-22 22:15:27 +02:00
Jelle Zijlstra
73b4c21cce Make ZipFile.__enter__ return self (#5675) 2021-06-22 17:01:11 +02:00
Sebastian Rittau
3ec061022a Improve logging.StreamHandler and FileHandler (#5663)
* Use PEP 604, instead of Optional.
* Override FileHandler.stream and setStream to require a TextIOWrapper
  instead of a SupportsWrite object.
* FileHandler._open() now returns a TextIOWrapper instead of IO. Using
  anything but a file opened in text mode would not work.
2021-06-21 22:50:49 +02:00
layday
5a256a0c70 Fix sysconfig.get_path return type (#5659)
`get_path` uses key access and raises `KeyError` for missing keys.
2021-06-18 12:45:23 +02:00
Thomas Grainger
74091411ea widen contextlib._SupportsClose and _SupportsAclose (#5655) 2021-06-17 11:58:49 +03:00
Maarten ter Huurne
0d9521970d Mark enum.Flag.name as Optional[str] (#5611)
* Mark enum.Flag.name as Optional[str]

* Annotate enum.Flag.value
2021-06-16 19:25:47 +03:00
Jelle Zijlstra
e58070cd35 socket: allow ReadableBuffer on send* methods (#5648) 2021-06-16 15:36:56 +02:00
Sebastian Speitel
04d81a8499 Allow merging dicts of different types (#5520) 2021-06-16 06:03:15 -07:00
joooeey
3072046430 Add Python 3.9 support in logging.basicConfig (#5639) 2021-06-15 11:33:38 +02:00
Jelle Zijlstra
4581501c98 use ParamSpec for @contextmanager (#5476) 2021-06-14 16:38:39 +02:00
Josh Smith
9565c595ca use TextIOWrapper for sys.__stdin__, sys.__stdout__, sys.__stderr__ (#5623) 2021-06-12 22:53:27 +02:00
Dominic Davis-Foster
48a346920b Use a TypeVar for the return types of TarFile classmethods. (#5602)
* Use a TypeVar for the return types of TarFile classmethods.

* Add TypeVar annotation to TarFile.__enter__
2021-06-12 10:54:34 +03:00