Commit Graph

4679 Commits

Author SHA1 Message Date
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
Hong Minhee (洪 民憙)
49fca14a15 Narrower return type for east_asian_width() (#9223)
Narrower return type for east_asian_width()
2022-11-18 21:58:13 -08:00
Bruce Merry
de12b1413d Refine types for asyncio transports (#9209)
- Change the return type of create_connection, start_tls,
  connect_accepted_socket, create_unix_connection to Transport
  rather than BaseTransport (closes #9199).
- Change the return type of create_datagram_endpoint to
  DatagramTransport rather than BaseTransport.
- Change the argument of sendfile to WriteTransport rather than
  BaseTransport.

I considered also changing the argument of start_tls to Transport, but
I think that will give false positives for code that implements a custom
transport class that inherits from both ReadTransport and WriteTransport
but not from Transport, and I'm not sure if typing has a way to express
an intersection of types. Since users are not normally expected to
implement transports that may be overthinking things.
2022-11-16 07:00:38 -08:00
Nikita Sobolev
e8111ea017 DecimalTuple can have string exponent (#9194) 2022-11-14 11:09:16 +01:00
Nikita Sobolev
0bd4e3ce1a ip_interface can have tuple arguments (#9195) 2022-11-14 11:02:56 +01:00
kasium
f9cd5ee859 Improve ast types; revert several "redundant numeric union" changes from #7906 (#9130)
* Adapt number types in ast

Since mypy  0.990 type promotions was limited.
This means that complex is not longer promoted to int/float, therefore
we should adapt the types to list all possible types

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: AlexWaygood <alex.waygood@gmail.com>
2022-11-14 09:41:23 +00:00
Anh71me
39d37ec54c types: add __getitem__ on GenericAlias (#9172)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-11-13 06:45:56 -08:00
Akuli
02f2bc30e7 Make peewee stubs compatible with peewee 3.15.4 (#9176) 2022-11-12 16:12:55 -08:00
Ben Blank
f5459640f8 Add None as a valid type in SAXParseException's second argument (#9162)
Closes #9161
2022-11-11 12:18:22 -08:00
Nikita Sobolev
70c4af4b73 Refactor round and add tests (#9151)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2022-11-11 18:19:51 +00:00
Nikita Sobolev
0f33721c52 Remove sqlite3/dbapi2.pyi from pyright excludelist (#9148) 2022-11-11 12:00:19 +00:00
Nikita Sobolev
0baadae0c9 urllib.parse: improve bytes handling (#9103) 2022-11-10 20:47:57 -08:00