Commit Graph

9641 Commits

Author SHA1 Message Date
Alex Waygood
ad96829bfa Remove linters from requirements-tests.txt (#12725) 2024-10-05 14:37:27 +01:00
Stephen Morton
77510ae6a4 resort _ast and ast modules (#11162)
The classes imported from the _ast module are defined in C,
but set their __module__ to ast. This arrangement ensures that
the type stubs have the same.

related to https://github.com/python/typeshed/issues/3968
and the discussion in https://github.com/python/typeshed/issues/11141
2024-10-04 17:33:45 -07:00
Stephen Morton
39650b43b5 add _sqlite3 module (#11174)
This aligns with the implementation while giving greater fidelity
to runtime naming and inheritance

Related to https://github.com/python/typeshed/issues/3968 and https://github.com/python/typeshed/issues/11141
2024-10-04 17:28:26 -07:00
danieleades
99095f5437 improve type annotations in 'docutils.frontend' (#12735)
Co-authored-by: daniel.eades <daniel.eades@seebyte.com>
2024-10-04 09:10:09 -07:00
Philipp Hahn
277202cf7e Xmlrpc: accept data:str|bytes and require method:str (#12734)
Declared <https://github.com/python/cpython/blob/main/Lib/xmlrpc/server.py#L622>

Inside
[`do_POST()`](https://github.com/python/cpython/blob/main/Lib/xmlrpc/server.py#L493)
`data: bytes`, where `decode_request_content()` only handles `gzip`
compression.
The `result` is then written to `self.wfile`, which uses `bytes`.

But for
[CGI](https://github.com/python/cpython/blob/main/Lib/xmlrpc/server.py#L636)
`str` is used: [`handle_xmlrpc(self,
request_text)`](https://github.com/python/cpython/blob/main/Lib/xmlrpc/server.py#L642)
calls the argument `request_text`, which is read from `sys.stdin` as
type `str` and then passed to `_marshaled_dispatch()`, which internally calls
[`xmlrpc.client.loads()`](https://github.com/python/cpython/blob/main/Lib/xmlrpc/server.py#L257)
to parse the XML using Expat, which accepts both `str` and `bytes`; the
later defaults to encoding `utf-8`, but other encodings can be
used when explicitly specified:

>>> xmlrpc.client.loads('<params><param><value><string>ä</string></value></param></params>')
(('ä',), None)
>>> xmlrpc.client.loads('<params><param><value><string>ä</string></value></param></params>'.encode("utf-8"))
(('ä',), None)
>>> xmlrpc.client.loads('<params><param><value><string>ä</string></value></param></params>'.encode("iso-8859-1"))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.11/xmlrpc/client.py", line 1029, in loads
    p.feed(data)
  File "/usr/lib/python3.11/xmlrpc/client.py", line 451, in feed
    self._parser.Parse(data, False)
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 3, column 15
>>> xmlrpc.client.loads('<?xml version="1.0" encoding="utf-8"?><params><param><value><string>ä</string></value></param></params>'.encode("iso-8859-1"))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.11/xmlrpc/client.py", line 1029, in loads
    p.feed(data)
  File "/usr/lib/python3.11/xmlrpc/client.py", line 451, in feed
    self._parser.Parse(data, False)
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 68
>>> xmlrpc.client.loads('<?xml version="1.0" encoding="iso-8859-1"?><params><param><value><string>ä</string></value></param></params>'.encode("iso-8859-1"))
(('ä',), None)

Signed-off-by: Philipp Hahn <hahn@univention.de>
Reviewed-By: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-10-04 07:12:02 -07:00
sobolevn
d16fe74e1f Fix _csv.Dialect.__init__ (#12320) 2024-10-03 11:33:56 +02:00
Sebastian Rittau
848cf9103d Remove Pillow stubs (#12732) 2024-10-03 11:33:09 +02:00
jonathan-h-grebe
735942adb0 Add missing ssl related arguments to Redis from_url method (#12166) 2024-10-02 21:24:56 -07:00
danieleades
bdc4c8c618 add type annotations for 'docutils.parsers.rst.directives.admonitions' (#12396) 2024-10-02 20:41:50 -07:00
Sebastian Rittau
975760281c tarfile.open(): Handle all modes (#12181) 2024-10-02 20:35:56 -07:00
danieleades
8228faa87d add type annotations to docutils.writers (#12420)
Co-authored-by: daniel.eades <daniel.eades@seebyte.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: James Addison <55152140+jayaddison@users.noreply.github.com>
2024-10-02 20:31:35 -07:00
Sebastian Rittau
26b3c69ee4 Add option to keep tmp dir to stubtest script (#12151) 2024-10-02 19:48:52 -07:00
Sebastian Rittau
8acc85dbab dateutil: Enable failing test (#11612) 2024-10-02 16:39:30 -07:00
Alex Waygood
45f96fe343 Move multiprocessing test-case file to the right place (#12727) 2024-10-02 16:36:24 +01:00
Alex Waygood
061f562935 gevent: remove unused allowlist entry (#12726) 2024-10-02 16:28:06 +01:00
Sebastian Rittau
2bf4edd901 [icalendar] Update to 6.0.0 (#12706) 2024-10-02 16:49:26 +02:00
Sebastian Rittau
e4c84dfb11 Make email.policy classes generic (#12724) 2024-10-02 16:42:07 +02:00
Sebastian Rittau
f266dc226a Change RawIOBase return types from None to MaybeNone (#12686) 2024-10-02 07:11:23 -07:00
Robsdedude
e05f3f083f Fix: pytz: is_dst parameter (#12723) 2024-10-02 13:11:12 +02:00
Stephen Morton
719ddd1774 move re.error into re.pyi (#11188) 2024-10-02 11:26:44 +02:00
Sebastian Rittau
6ba6589144 Support environment markers in requires fields (#12711) 2024-10-02 10:14:33 +02:00
Jelle Zijlstra
213ca9eb81 Update vobject (#12721) 2024-10-02 08:27:21 +01:00
renovate[bot]
481230077b Update dependency pyright to v1.1.383 (#12722)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-02 07:33:36 +01:00
Pradeep Kumar
b54dcc6783 [str] Add LiteralString overload for __getitem__ (#12714)
In PEP 675, Graham Bleaney and I had specified a list of `LiteralString`-preserving [overloads](https://peps.python.org/pep-0675/#appendix-c-str-methods-that-preserve-literalstring) for `str`. However, we didn't specify an overload for `__getitem__` and didn't give any rationale either. IIRC this was an edge case we didn't want to take a strong decision on unless users wanted it.

Carl Meyer brought this up yesterday, so I think it's worth discussing.

Pro: `my_literal_string[i]` or `my_literal_string[i:j]` should technically be compatible with `LiteralString`, since it is a substring of a literal-derived string.

Con: The main downside is that an attacker might control the indexes and try to access a specific substring from a literal string in the code. For example, they might narrow down the string to `rm foo` or `SELECT *`.

It's true that `join` and other methods could also construct dangerous strings from `LiteralString`s, and we even call that out as an accepted tradeoff in the PEP:

> 4. Trivial functions could be constructed to convert a str to a LiteralString:
>
>     def make_literal(s: str) -> LiteralString:
>         letters: Dict[str, LiteralString] = {
>             "A": "A",
>             "B": "B",
>             ...
>         }
>         output: List[LiteralString] = [letters[c] for c in s]
>         return "".join(output)
>
> We could mitigate the above using linting, code review, etc., but ultimately a clever, malicious developer attempting to circumvent the protections offered by LiteralString will always succeed. The important thing to remember is that LiteralString is not intended to protect against malicious developers; it is meant to protect against benign developers accidentally using sensitive APIs in a dangerous way (without getting in their way otherwise).
>
> Without LiteralString, the best enforcement tool API authors have is documentation, which is easily ignored and often not seen. With LiteralString, API misuse requires conscious thought and artifacts in the code that reviewers and future developers can notice.
>
> -- [PEP 675 - Appendix B: Limitations](https://peps.python.org/pep-0675/#appendix-b-limitations)

`__getitem__`, however, seems a bit different, because it (and `split`, `zfill`, etc.) accept an index or width that could be used to construct a dangerous query or a humongous string. So, we need to clarify the intent a little.

What was the intent of these overloads? We wanted to forbid "arbitrary user-supplied strings" while allowing methods that preserved literal strings. We were not trying to prevent every possible exploit on the string. Since `__getitem__` forbids arbitrary user-supplied strings and preserves literal strings, I think we should add an overload for it.
2024-10-01 20:29:00 -07:00
Stephen Morton
4f37d8fff8 add _ssl module (#11155)
Really all I needed for fixing the inheritance was _ssl._SSLContext.
But then I needed all the other stuff in _ssl, and if I was doing that
I wanted to do a thorough job of it.

Motivation was originally related to https://github.com/python/typeshed/issues/3968 ,
but we're well beyond that now, really.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-10-01 20:10:51 -07:00
Stephen Morton
c43894568f resort weakref classes (#11165)
This improves fidelity of naming and inheritance on 3.11+

related to https://github.com/python/typeshed/issues/3968 and https://github.com/python/typeshed/issues/11141

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-10-01 19:50:10 -07:00
Stephen Morton
6bc1884577 follow implementation more closely in zoneinfo (#11189)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-10-01 19:49:01 -07:00
github-actions[bot]
e9c7346b0e [stubsabot] Bump reportlab to 4.2.5 (#12719)
Release: https://pypi.org/pypi/reportlab/4.2.5
Homepage: https://www.reportlab.com/
Repository: https://github.com/MrBitBucket/reportlab-mirror
Typeshed stubs: https://github.com/python/typeshed/tree/main/stubs/reportlab

If stubtest fails for this PR:
- Leave this PR open (as a reminder, and to prevent stubsabot from opening another PR)
- Fix stubtest failures in another PR, then close this PR

Note that you will need to close and re-open the PR in order to trigger CI

Co-authored-by: stubsabot <>
2024-10-01 18:50:57 -07:00
github-actions[bot]
a1088d09b0 [stubsabot] Bump qrcode to 8.0.* (#12718)
Release: https://pypi.org/pypi/qrcode/8.0
Homepage: https://github.com/lincolnloop/python-qrcode
Repository: https://github.com/lincolnloop/python-qrcode
Typeshed stubs: https://github.com/python/typeshed/tree/main/stubs/qrcode
Diff: https://github.com/lincolnloop/python-qrcode/compare/v7.4.2...v8.0

Stubsabot analysis of the diff between the two releases:
 - 2 public Python files have been added: `qrcode/compat/png.py`, `qrcode/tests/consts.py`.
 - 0 files included in typeshed's stubs have been deleted.
 - 12 files included in typeshed's stubs have been modified or renamed.
 - Total lines of Python code added: 669.
 - Total lines of Python code deleted: 727.

If stubtest fails for this PR:
- Leave this PR open (as a reminder, and to prevent stubsabot from opening another PR)
- Fix stubtest failures in another PR, then close this PR

Note that you will need to close and re-open the PR in order to trigger CI

Co-authored-by: stubsabot <>
2024-10-01 18:50:48 -07:00
Stephen Morton
ddb57608fd move pyexpat.ExpatError to xml.parsers.expat.ExpatError (#11168)
This matches the name reported by the cass at runtime.

related to https://github.com/python/typeshed/issues/11141

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-10-01 18:45:11 -07:00
Avasam
bdb5b52d50 Make multiprocessing pipes generic (#11137) 2024-10-01 18:11:42 -07:00
renovate[bot]
44aa63330b Update most test/lint dependencies (#12713) 2024-10-01 14:38:01 +02:00
DinhHuy2010
1c96234848 add stubs for m3u8 (#12683) 2024-10-01 14:05:59 +02:00
github-actions[bot]
302e83f003 [stubsabot] Bump Flask-SocketIO to 5.4.* (#12712)
Release: https://pypi.org/pypi/Flask-SocketIO/5.4.0
Homepage: https://github.com/miguelgrinberg/flask-socketio
Repository: https://github.com/miguelgrinberg/flask-socketio
Typeshed stubs: https://github.com/python/typeshed/tree/main/stubs/Flask-SocketIO
Diff: https://github.com/miguelgrinberg/flask-socketio/compare/v5.3.7...v5.4.0

Stubsabot analysis of the diff between the two releases:
 - Total lines of Python code added: 40.
 - Total lines of Python code deleted: 11.

If stubtest fails for this PR:
- Leave this PR open (as a reminder, and to prevent stubsabot from opening another PR)
- Fix stubtest failures in another PR, then close this PR

Note that you will need to close and re-open the PR in order to trigger CI

Co-authored-by: stubsabot <>
2024-10-01 09:23:44 +01:00
Dima Tisnek
c47650323e fix: correct headers= kwarg in HTTP[S]Connection (#12704) 2024-10-01 08:59:46 +02:00
Sebastian Rittau
91a58b07cd Amend third-party removal policy (#12710)
Upstream annotations should have a similar standard as typeshed's.
2024-09-30 22:04:29 +02:00
Sebastian Rittau
3b385903a1 Pass Requirement objects around (#12709)
This allows us to keep metadata like python_version and platform_system
and use it to conditionally install packages.
2024-09-30 17:45:58 +02:00
Semyon Pupkov
06b50fcc27 Fix yeardatescalendar, yeardays2calendar, yeardayscalendar return types (#12703) 2024-09-30 13:47:49 +02:00
Sebastian Rittau
7ce17a95f6 Document to stubtest_requirements field in the proper place. (#12707) 2024-09-30 13:46:48 +02:00
Victorien
db265afec5 Use Mapping for local Python namespace parameters (#12705) 2024-09-30 11:26:41 +02:00
David Salvisberg
6990bb64a9 Bump reportlab to 4.2.4 (#12701) 2024-09-29 13:35:05 +02:00
renovate[bot]
119cd09655 Update dependency pyright to v1.1.382.post1 (#12699)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-27 17:34:39 -07:00
Jinzhe Zeng
d828a5ef92 paramiko: add ProxyCommand to _SocketLike (#12697) 2024-09-27 22:36:10 +02:00
Matthias Schoettle
283ff95ea0 [fpdf2] fix link type to support internal links (#12695) 2024-09-26 20:56:54 +02:00
renovate[bot]
5a89c481dc Update dependency pyright to v1.1.382.post0 (#12692)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-26 20:33:59 +02:00
github-actions[bot]
a94c927642 [stubsabot] Bump braintree to 4.30.* (#12681)
Release: https://pypi.org/pypi/braintree/4.30.0
Homepage: https://developer.paypal.com/braintree/docs/reference/overview
Repository: https://github.com/braintree/braintree_python
Typeshed stubs: https://github.com/python/typeshed/tree/main/stubs/braintree
Diff: https://github.com/braintree/braintree_python/compare/4.29.0...4.30.0

Stubsabot analysis of the diff between the two releases:
 - 0 public Python files have been added.
 - 0 files included in typeshed's stubs have been deleted.
 - 4 files included in typeshed's stubs have been modified or renamed: `braintree/error_codes.py`, `braintree/transaction.py`, `braintree/version.py`, `braintree/webhook_testing_gateway.py`.
 - Total lines of Python code added: 317.
 - Total lines of Python code deleted: 278.
2024-09-24 23:08:38 -07:00
Akuli
13a74a5211 Update tkinter.Text.count() for Python 3.13 (Akuli's version) (#12629) 2024-09-24 23:08:11 -07:00
kasium
6cddd30ff2 Add basic jwcrypto stubs (#12687) 2024-09-24 10:30:58 +02:00
Alex Waygood
9f033bf439 Fixup some pyright CI configuration details (#12690) 2024-09-23 13:07:57 -07:00
github-actions[bot]
bfaa3d2d5a [stubsabot] Bump hdbcli to 2.22.* (#12676)
Co-authored-by: stubsabot <>
2024-09-23 12:15:59 -07:00