Commit Graph

3932 Commits

Author SHA1 Message Date
Alex Waygood
b0f2bd68b0 Improve tempfile.SpooledTemporaryFile (#7196) 2022-02-13 17:41:54 -08:00
Alex Waygood
65002d2e69 threading: Semaphore.__exit__ & _RLock.__exit__ always return None (#7195)
`_RLock.__exit__`: 1d6ce67c29/Lib/threading.py (L199)
`Semaphore.__exit__`: 1d6ce67c29/Lib/threading.py (L487)
2022-02-13 17:41:17 -08:00
Alex Waygood
cabfaabd76 optparse.HelpFormatter: format_heading and format_usage are abstract methods (#7194)
The [docstrings state](0ae4019179/Lib/optparse.py (L255-L259)) "Subclasses must implement", and the [docs for optparse](https://docs.python.org/3/library/optparse.html) explicitly state that `TitledHelpFormatter` and `IndentedHelpFormatter` are provided as "concrete implementations" of `optparse.HelpFormatter`.
2022-02-13 17:41:00 -08:00
Alex Waygood
68e2a74a79 pathlib.Path.__exit__ always returns None (#7192)
Source code here: 0ae4019179/Lib/pathlib.py (L893)

It has always returned `None`, by the looks of things.
2022-02-13 17:14:13 -08:00
Alex Waygood
0109a371d6 Improve webbrowser stubs (#7190)
- `BaseBrowser.open` is an abstract method that should be overridden in all subclasses.
- `UnixBrowser.open` only accepts 0, 1 or 2 for the `new` parameter.
2022-02-13 17:10:43 -08:00
Alex Waygood
7f472e94e5 Improve collections.UserString (#7189) 2022-02-13 17:09:06 -08:00
Alex Waygood
63489c305d asyncio: make AbstractServer abstract and remove unnecessary metaclass=ABCMeta (#7185) 2022-02-13 23:34:19 +02:00
Nikita Sobolev
5014f9f50c Improve __reduce__ signature accross stdlib (#7182) 2022-02-13 12:24:27 +01:00
Nikita Sobolev
6882e513c2 Improve Self type usage accross stdlib (#7183) 2022-02-13 12:21:01 +01:00
Alex Waygood
03dbe2206c Improve pathlib stubs (#7181) 2022-02-12 18:42:04 -08:00
Nikita Sobolev
2ce1844905 Fix context type in pprint.PrettyPrinter.format (#7179)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-02-12 11:51:29 -08:00
Nikita Sobolev
3b05794ba9 Improve poplib with Literal values (#7180) 2022-02-12 19:24:18 +02:00
Sebastian Rittau
92685d18f7 Update to Python 3.9.10 and 3.10.2 (#6977) 2022-02-11 17:37:31 -08:00
Nikita Sobolev
418574f82c Improve socketserver (#7073)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2022-02-11 17:22:00 -08:00
Luna Nova
846c2dfa4f Add locale.gettext and related stubs, fixes #7164 (#7165) 2022-02-11 17:18:45 -08:00
Ilya Kulakov
d014533f36 bisect: elements of a are bounded by SupportsRichComparison (#7111) 2022-02-11 17:12:00 -08:00
Nikita Sobolev
9150db52a6 Improve pstats typing (#7174)
* Add __all__
* Use Literal for Stats.sort_stats() argument type.
* Add FunctionProfile, StatsProfile, and Stats.get_stats_profile() (Python 3.9+)
2022-02-11 12:30:00 +01:00
Jelle Zijlstra
7dd2485269 New additions to typing, typing_extensions (#7169) 2022-02-08 22:40:09 -08:00
Dmitry Volodin
be5a109c03 Fix zero exponent for ints (#7163) 2022-02-08 14:08:00 -08:00
Alex Waygood
4b75ecbbe2 Use Self in Python 2's array.__imul__ (#7167) 2022-02-08 10:54:16 -08:00
Alex Waygood
5f830d023f Backport more Self-related changes to Python 2 (#7166) 2022-02-08 09:52:43 -08:00
Nikita Sobolev
da1f46adae Add precise types for underlying queue objects (#7157) 2022-02-08 07:06:59 -08:00
Joshua Bronson
9a257c18bb Add missing type hint for AbstractSet._hash(). (#7153) 2022-02-08 06:18:52 -08:00
Alex Waygood
398a5807a1 Return Self from MutableSequence.__iadd__ (#7162) 2022-02-08 06:15:37 -08:00
Alex Waygood
b1b3471c76 Improve in-place BinOp methods for sets (#7161) 2022-02-08 14:57:50 +01:00
Nikita Sobolev
a906d54742 Improve pydoc typings (#7152)
Enforce same type HTMLDoc.multicolumn "list" and "format" arguments.

Annotate ModuleScanner.run "key" argument.
2022-02-08 13:54:57 +01:00
Alex Waygood
494481a0ae Improve a bunch of __(deep)copy__ methods (#7148) 2022-02-06 15:40:44 -08:00
Alex Waygood
a62fd92fb0 Improve some in-place BinOp methods (#7149) 2022-02-06 15:36:57 -08:00
Itai Steinherz
3b8412650e Improve filecmp typing (#7147) 2022-02-06 23:25:12 +02:00
Nikita Sobolev
8cb1518bcd Improve readline typings (#7141) 2022-02-06 11:31:19 +02:00
Nikita Sobolev
c42bfc5710 Add __all__ to runpy (#7140) 2022-02-05 20:23:47 +02:00
Alex Waygood
348c38a0dd Improve __all__ definitions for threading and _dummy_threading modules (#7135) 2022-02-05 08:07:02 -08:00
Nikita Sobolev
bdef0a70a6 Improve sched typings (#7138) 2022-02-05 07:36:43 -08:00
Alex Waygood
287c8c3d79 Add __all__ to copyreg stubs (#7137) 2022-02-05 07:28:15 -08:00
Alex Waygood
004f12a1eb Add __all__ to _osx_support (#7136) 2022-02-05 07:27:01 -08:00
Jelle Zijlstra
c1e3be1248 zip.__iter__ and reversed.__iter__ return self (#7123) 2022-02-05 15:53:29 +02:00
Sebastian Rittau
7179fee2d8 is_zipfile() also accepts bytes paths (#7106)
Use a protocol for is_zipfile(), instead of IO
2022-02-04 21:27:02 -08:00
Stephen Rosen
38d32a916c Use enum trick for dataclasses.MISSING (#7127)
The goal of this change is to fix the behavior of
`dataclasses.Field`. Several attributes of a `Field` may have a value
of `MISSING` (a sentinel value). As a result, attributes of Field may
be checked against `MISSING` as in

     [f for f in fields(obj) if f.default is MISSING]

`default`, `default_factory`, and `kw_only` are the attributes
which may have a value of `MISSING`.

This workaround of defining `_MISSING_TYPE` as an enum, and `MISSING`
as its only member, allows `... | Literal[_MISSING_TYPE.MISSING]` to
be used in type annotations for these attributes. This is very
slightly inaccurate -- primarily in that `_MISSING_TYPE` isn't really
an enum -- but this allows for use in `Literal`.
After PEP 661 (Sentinel Values), there may be a more accurate way of
writing this, but for now this works.

This adjustment is only applied to the attributes of Field, not the
arguments to functions and methods.
2022-02-04 21:21:12 -08:00
Nikita Sobolev
819f8dfc10 Improve ipaddress module (#7129) 2022-02-04 21:19:34 -08:00
Eric Traut
7dc5bed72c Changed typing_extensions.pyi to declare its own private version of Protocol (#7133)
Changed typing_extensions.pyi to declare its own private version of `Protocol` and `runtime_checkable` rather than re-exporting the symbols imported from `typing`. This allows pyright to warn users about runtime exceptions when they attempt to use typing.Protocol on versions of Python prior to 3.7.
2022-02-04 21:02:58 -08:00
Alex Waygood
1371a1e1fe unittest deprecations have been deferred until 3.12 (#7131)
See https://github.com/python/cpython/pull/30935
2022-02-04 15:52:30 -08:00
Alex Waygood
51cdd2c6be Backport many Self-related changes to the Python-2 stdlib (#7128) 2022-02-04 10:10:05 -08:00
Thomas Grainger
57b2bae031 correct asyncio.locks._ContextManagerMixin and _ContextManager types (#7124)
Co-authored-by: Akuli <akuviljanen17@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2022-02-04 18:30:55 +02:00
Thomas Grainger
4e67419b1f most asyncio lock methods always return True (#7122) 2022-02-04 11:18:17 +02:00
Shantanu
4d21d5a87d codecs: allow str to bytes decoding for "hex", fix overloads (#7118)
Fixes #7115

Co-authored-by: hauntsaninja <>
2022-02-03 14:20:11 -08:00
Alex Waygood
26e8959279 Use _typeshed.Self in docutils.VersionInfo and os.sched_param (#7117) 2022-02-02 23:30:39 +01:00
PabloLION
0ccbc29919 fix: enable encode/decode from/to hex string (#7115) 2022-02-02 23:05:16 +01:00
Alex Waygood
7ccbbdb30a stdlib: Improve many __iter__ and constructor methods (#7112) 2022-02-02 19:14:57 +01:00
Alex Waygood
27c7aece10 Update asyncio.trsock to reflect methods removed in 3.11 (#7110)
* Update `asyncio.trsock` to reflect methods removed in 3.11

These were all removed in https://bugs.python.org/issue43232

* [pre-commit.ci] auto fixes from pre-commit.com hooks

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-02-02 09:44:26 -08:00
Alex Waygood
806c26045e Improve itertools stubs (#7109)
There are quite a few `__iter__` methods in `itertools` that return `self` at runtime. They should do so in the stubs as well.

Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
2022-02-02 08:37:41 -08:00