Commit Graph

4690 Commits

Author SHA1 Message Date
Avasam
c70d303985 Audit stdlib object annotations (#9519) 2023-01-17 15:40:00 +00:00
Alex Waygood
597e1a0078 Bump various test dependencies (#9549) 2023-01-16 11:04:45 -08:00
Kalle Møller
6b23df3db6 Update _FilterType to retuning bool (#9514) 2023-01-16 16:12:40 +01:00
James Hilton-Balfe
62170653ce Add itertools.batched (#9515) 2023-01-12 22:07:26 +00:00
Jelle Zijlstra
b43e1db47b ssl, sysconfig: fix issues with defaults (#9507)
- ssl._create_unverified_context allows None since 3.10:
  2875c603b2 (diff-f6439be9c66350dde4c35dbeea0352c96cc970ba12b0478f6ae36f10725bd8c5)
- sysconfig.is_python_build ignores its argument since 3.11:
  067597522a
  (was backported into 3.11)
2023-01-12 10:19:41 -08:00
Avasam
aad1a14890 Use the FileDescriptorOrPath alias consistently in the stdlib (#9513) 2023-01-12 18:14:48 +00:00
Jelle Zijlstra
f64807a468 socketserver: improve bytes handling (#9096)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-01-12 16:46:20 +00:00
Jelle Zijlstra
b9eab637cb subprocess: Improve bytes-related types (#9100) 2023-01-11 20:10:26 -08:00
Jelle Zijlstra
6a366c99a9 venv: add logger (#9508)
Not particularly useful but unreleased stubtest will require this:
https://github.com/python/typeshed/actions/runs/3898630022/jobs/6657546205
2023-01-11 19:33:16 -08:00
Jelle Zijlstra
1ce1c1ad17 subprocess: universal_newlines may be None (#9509)
All the way back to 3.7:
https://github.com/python/cpython/blob/3.7/Lib/subprocess.py#L684

It's treated like False
2023-01-11 19:15:40 -08:00
Jelle Zijlstra
d2829ecdf7 urllib.parse.urlencode: encoding and errors can be None (#9506)
The runtime defaults are None. Found in #9501.
2023-01-11 18:55:38 -08:00
Shantanu
fa204f6bd4 Update compileall stripdir type (#9404)
See https://github.com/python/cpython/pull/19883
2023-01-08 22:26:33 -08:00
Avasam
41de5317b5 Add FileDescriptorOrPath and Unused type aliases (#9475) 2023-01-08 10:05:51 +00:00
Martin Fischer
554989e31f stdlib: Fix types of semi-public Message methods (#9456) 2023-01-04 11:21:33 +01:00
Ethan Furman
3aceb1abd5 Update SimpleHTTPRequestHandler for changes in 3.12 (#9452)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-01-03 23:59:40 +00:00
Ned Batchelder
379d449894 zipimporter.get_data returns bytes, not str(#9428)
Fixes #9427
2022-12-29 13:59:51 -08:00
Nikita Sobolev
6f6dad117d compile can only work with ast.Module | ast.Expression | ast.Interactive (#9424) 2022-12-29 11:25:07 +01:00
Avasam
23ac9bff19 Check for unused pyright: ignore and differentiate from mypy ignores (#9397) 2022-12-28 10:44:29 +00:00
Alex Waygood
27983aa929 ast.NodeVisitor: add visit_TryStar on 3.11+ (#9418) 2022-12-27 18:36:53 +01:00
Will Frey
f174355b31 Allow indent to be str in JSONEncoder (#9417) 2022-12-27 16:26:16 +01:00
Alex Waygood
116229d0ac datetime: various parameters can now safely be passed as keyword arguments on 3.12+ (#9415) 2022-12-27 14:35:29 +00:00
zhykzhykzhyk
d6237d09c7 Add constructor to CellType (#9399) 2022-12-26 20:43:35 -08:00
Alex Waygood
154452ffc2 ast.NodeVisitor: Add visit_* methods for ast nodes new in 3.8-3.10 (#9413) 2022-12-26 20:27:44 -08:00
Nikita Sobolev
0e4c59a076 ast.get_docstring does not work with arbitrary AST nodes (#9407) 2022-12-24 18:43:44 +00:00
Will Frey
9befe5ff00 Update json.dump to only require fp: SupportsWrite[str] (#9396)
Presently, `json.dump` requires `fp` be of type `IO[str]` but in reality and according to the docs, `json.dump` only requires ` SupportsWrite[str]`.
2022-12-21 11:00:27 -08:00
Alex Waygood
352f496d69 Unpin stubtest from Python 3.10.8 and 3.11.0 (#9368) 2022-12-20 20:31:13 +00:00
Коренберг Марк
bff43b53e5 Update asyncio subprocess optional **kwargs (#9177) 2022-12-18 09:51:31 -08:00
Sam Bull
62accb35b8 Improve netrc types on py311+ (#9376) 2022-12-17 14:02:22 +00:00
Jukka Lehtosalo
2b20b70cf2 Revert "Use Literal for compression in zipfile (#9346)" (#9367)
This reverts commit 034cfab4d6.

The commit exposed the value of the compression constants, which seem
to be implementation details, in the public API. I don't see anything
in the documentation about the values of the constants such as
`ZIP_STORED`:
https://docs.python.org/3/library/zipfile.html?highlight=zipfile#zipfile.ZipFile

Example where this makes a difference:
```
from typing import Literal
import zipfile

def f1(p: str, compression: int) -> None:
    """Error: compression should have the type Literal[0, 8, 12, 14]"""
    zipfile.ZipFile(p, compression=compression)

def f2(p: str, compression: Literal[0, 8, 12, 14]) -> None:
    """Works, but cryptic and exposes internal implementation details"""
    zipfile.ZipFile(p, compression=compression)
```

The values are of constants need to be explicitly specified if somebody
wants to wrap `zipfipe.ZipFile`, which arguably exposes implementation
details in a problematic fashion.

Here is a real-world example where this caused a regression:
https://github.com/pytorch/vision/blob/main/torchvision/datasets/utils.py#L301
2022-12-16 13:49:16 +00:00
Alex Waygood
c78bc57f78 shutil.rmtree: add avoids_symlink_attacks attribute (#9366) 2022-12-15 09:56:58 +00:00
Viicos
034cfab4d6 Use Literal for compression in zipfile (#9346) 2022-12-14 10:46:15 +00:00
Lucina
da2d39f16d Mark asyncio.Runner as final (#9353)
As per 71b032635d/Lib/asyncio/runners.py (L47)
2022-12-12 00:33:30 -08:00
Lucina
ae41747836 Add loop_factory argument to asyncio.run on 3.12+ (#9354) 2022-12-12 07:07:31 +00:00
Terrance
4661af99c3 Annotate unittest.TestCase.skipTest() as no-return (#9352)
Annotate unittest.TestCase.skipTest() as no-return

This method unconditionally raises unittest.SkipTest, which ends a test
method early.  unittest.TestCase.fail() works similarly, and is already
annotated with NoReturn to indicate this behaviour.
2022-12-11 18:07:09 +00:00
Dominik Lenart
75d5a5b936 Improve typing for ast nodes which represent assignment behaviour (#9326) 2022-12-11 16:54:38 +00:00
Joshua Bronson
1ba0c9815e Fix false positive with calling .register() on KeysView subclass (#9348)
* Revert "`Collection` is `Sized` (#8977)"

This reverts commit 5bbba5d008.

* Revert "typing: remove metaclass from Sized (#9058)"

This reverts commit a3ce512095.

* Add regression test for issue 9296.
2022-12-10 10:09:28 -08:00
Sebastian Rittau
a74df38df0 Message.get_content_charset() returns None by default (#9344) 2022-12-09 07:19:18 -08:00
Mike Placentra
89fb1d5521 fix type for multiprocessing.log_to_stderr(): allow int level (#9334)
Co-authored-by: AlexWaygood <alex.waygood@gmail.com>
2022-12-05 22:44:26 +00:00
Huazuo Gao
cdf5cc34f2 types: fix signature of coroutine (#9333) 2022-12-05 12:00:32 -08:00
Jelle Zijlstra
00483b63e6 http.client.HTTPConnection.request accepts str as the body (#9322)
See code around ab02262cd0/Lib/http/client.py (L1328)
2022-12-02 10:49:33 -08:00
Nikita Sobolev
ea2ccc3c21 Improve annotations for __instancecheck__, __subclasscheck__ (#9291) 2022-11-28 11:15:02 +00:00
Jelle Zijlstra
9452ce539c xmlrpc: improve bytes handling (#9166) 2022-11-25 19:33:53 -08:00
Jelle Zijlstra
8da1e8c31d marshal: specify allowed types (#9165) 2022-11-24 22:54:09 -08:00
Avasam
be1da49957 Suggestion: SliceableBuffer type alias (#9115)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-11-24 20:14:09 -08:00
Nikita Sobolev
bd75ceb0b6 Fix stdlib stubtest failures on main (#9255)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2022-11-23 10:07:05 +00:00
Nikita Sobolev
ae58142e6e Fix typings of ExceptionGroup and BaseExceptionGroup (#9230)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: AlexWaygood <alex.waygood@gmail.com>
2022-11-22 20:46:03 -08:00
Jelle Zijlstra
d2da97d99c urllib: improve bytes handling (#9167) 2022-11-22 16:38:28 -08:00
Nikita Sobolev
e1aa4d5285 Add types to multiprocessing/reduction.pyi (#9171) 2022-11-22 14:02:14 +00:00
Nikita Sobolev
18e2ae762b Mark first argument of __[get|set|del]attr__ as str (#9245) 2022-11-22 11:06:50 +00:00
chaojie
620e37fd02 Add type-hints for _vformat in string.Formatter (#9228) 2022-11-20 18:22:36 -08:00