Commit Graph

3293 Commits

Author SHA1 Message Date
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
Rebecca Turner
72f4057d81 Signal handler callables take int, not Signals (#5622)
The documentation for [`signal.signal`][1] points out that the current
annotation for signal handlers might be wrong (emphasis my own):

> The handler is called with two arguments: the signal **number** and the
> current stack frame (**`None` or** a frame object; for a description of frame
> objects, see the description in the type hierarchy or see the attribute
> descriptions in the `inspect` module).

And when we use them, we can see that the signal number is passed as an `int`,
not a `signal.Signals` member:

import signal

    def handler(signal_number, frame):
        print("In signal handler!")
        print("Signal number:", signal_number, type(signal_number))
        print("Stack frame:  ", frame, type(frame))

    # Set signal handler:
    signal.signal(signal.SIGHUP, handler)

    # Use it:
    signal.raise_signal(signal.SIGHUP)

Which prints:

    In signal handler!
    Signal number: 1 <class 'int'>
    Stack frame:   <frame at 0x7f804402abe0, file '<stdin>', line 12, code <module>> <class 'frame'>

[1]: https://docs.python.org/3/library/signal.html#signal.signal
2021-06-11 20:28:20 +03:00
Ethan Smith
cb76f32826 Allow passing complex to complex constructor (#5609) 2021-06-09 22:58:22 +02:00
Sebastian Rittau
711580722b Enable pyright for all Python 3 stubs (#5597)
* pyright: disable reportUnknownParameterType

Unknown parameter types are preferred over Any annotations for
incomplete stubs. Especially larger stubs are expected to be
incomplete for some time and it would be a shame to lose the
other pyright warnings for those stubs.

* Also disable reportUnknownVariableType

Fix problems with tkinter

* Disable reportUnknownMemberType

Fix pyright problems
2021-06-09 07:14:22 -07:00
Sebastian Rittau
87e805bce6 Remove AnyPath (#5592)
Part of #5470
2021-06-09 00:25:01 +02:00
Sebastian Rittau
52dd232a23 Rework Match.group handling (#5557)
* Rework Match.group handling

Standardize group(), groups(), groupdict(), and __getattr__() to return
Any instead of AnyStr. Also special case group(0) and __getattr__(0) to
always return AnyStr. Use PEP 604 for unions in changed lines.
2021-06-09 00:27:49 +03:00
Marc Mueller
bad2fea551 Use Literal for MatchSingleton (#5590) 2021-06-08 13:25:41 +02:00
Akuli
200260e685 move DndSource to tkinter/dnd.pyi (#5588) 2021-06-07 07:07:57 -07:00
Akuli
ec80fdaeb5 add types to most common tkinter.Entry methods (#5586)
* most common tkinter.Entry methods

* type-ignore tkinter's lsp violation
2021-06-07 11:55:35 +03:00
jack1142
0209b6f95f random.choices: weights can be Fractions (#5587) 2021-06-06 21:39:31 -07:00
Akuli
4b66a9cd4e add types to tkinter invoke methods (#5582) 2021-06-06 20:32:30 +02:00