Commit Graph

53 Commits

Author SHA1 Message Date
Nikita Sobolev
f7cb7f33b2 Use OSError instead of IOError (#9683) 2023-02-06 18:56:32 +00:00
Nikita Sobolev
c96079f0df urllib.HTTPError.headers is a settable property (#9682) 2023-02-06 18:56:08 +00:00
Jelle Zijlstra
5b24c7bb41 stdlib: Run stubdefaulter on Linux for 3.9 (#9663) 2023-02-03 00:39:22 +00:00
Alex Waygood
c54a1a9e16 urllib.parse: Fix issues with TypeVar usage and default values (#9629)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-01-31 02:21:50 +00:00
Alex Waygood
33a62ae42d Add more defaults to the stdlib (#9606)
Continuing work towards #8988.

The first five commits were created using stubdefaulter on various Python versions; the following commits were all created manually by me to fix various problems. The main things this adds that weren't present in #9501 are:

- Defaults in Windows-only modules and Windows-only branches (because I'm running a Windows machine)
- Defaults in non-py311 branches
- Defaults for float parameters
- Defaults for overloads
2023-01-29 01:51:23 +00:00
Jelle Zijlstra
ddfaca3200 stdlib: add argument default values (#9501) 2023-01-18 09:37:34 +01: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
Jelle Zijlstra
d2da97d99c urllib: improve bytes handling (#9167) 2022-11-22 16:38:28 -08:00
Nikita Sobolev
0baadae0c9 urllib.parse: improve bytes handling (#9103) 2022-11-10 20:47:57 -08:00
Nikita Sobolev
a74acc8225 urllib.response: improve bytes handling (#9142) 2022-11-09 18:21:13 -08:00
Anton Grübel
ccd468fd86 urllib.parse: extend unquote type hint and replace _Str with str | bytes (#8877) 2022-10-13 20:54:07 -07:00
Nikita Sobolev
0259068ad6 Remove duplicate definitions in sub-classes (#8594) 2022-08-26 17:10:55 +02:00
Alex Waygood
553700e355 Move some protocol definitions closer to their usage sites (#8436) 2022-07-29 06:26:27 -07:00
Alex Waygood
540a6b25bf Improve urllib.parse.urldefrag (#8204)
Fixes #2477
2022-07-19 07:05:09 -07:00
Alex Waygood
6348a58b8b Import Match and Pattern from re, not typing (#8277) 2022-07-12 15:32:48 +02:00
Alex Waygood
8b3b6bf7cd stdlib: Audit Callable[<parameters>, None] annotations (#8187) 2022-06-27 08:08:28 +02:00
Eric Werner
ec64372348 re-export HTTPError in urllib.request (#8146)
See cpython/#94204
2022-06-24 16:37:09 +02:00
Jelle Zijlstra
3dcfbf3745 urllib.request: add code 308 handler for 3.11 (#7917)
c379bc5ec9
2022-05-21 14:13:17 -07:00
Alex Waygood
e9526faf40 Various py311 removals (#7836) 2022-05-16 17:28:13 -07:00
Rebecca Chen
46fc7768c4 Add missing 'headers' property to urllib.error.HTTPError. (#7783)
Seen here: https://docs.python.org/3/library/urllib.error.html#urllib.error.HTTPError.headers
2022-05-05 14:05:51 -07:00
Alex Waygood
97a74bc1aa Import from collections.abc wherever possible (#7635) 2022-04-18 12:50:37 +02:00
Alex Waygood
740193a8fc Use TypeAlias where possible for type aliases (#7630) 2022-04-15 18:01:00 -07:00
Alex Waygood
61b22db692 Add many missing __match_args__ attributes (#7556)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-03-26 19:36:28 +00:00
Alex Waygood
3ab250eec8 Use PEP 604 syntax wherever possible (#7493) 2022-03-16 16:01:33 +01:00
Martin Fischer
14ac9f7557 stdlib: Add urllib.parse.unwrap(url) 2022-03-06 15:57:52 -08:00
Alex Waygood
c50cb066e0 Improve two classes which are namedtuples at runtime, but cannot be namedtuples in typeshed (#7429) 2022-03-03 07:22:40 -08:00
Alex Waygood
a0b41959ec stdlib: fix many attributes which are read-only at runtime but read-write in the stub (#7395) 2022-02-27 16:23:09 -08:00
Alex Waygood
58e505eeb2 Add __all__ for modules beginning with 'u', 'x', 'w' and 'z' (#7374) 2022-02-23 23:04:21 +01:00
Shantanu
feb20fc20a urllib.request: loosen data type (#7211)
Fixes #7208

This is what urllib.request claims to support over here:
ad4e8d2b87/Lib/urllib/request.py (L1276)

There is additional validation logic (e.g. strs don't work), but a lot
of what determines what works is over here:
ad4e8d2b87/Lib/http/client.py (L1039)
2022-02-15 06:44:28 -08:00
Alex Waygood
66a229b709 stdlib: Add several missing comparison methods (#7202) 2022-02-14 11:09:52 -08:00
Shantanu
b88a6f19cd Upgrade black version (#7089) 2022-01-30 16:27:06 -08:00
q0w
4e97b06175 Use MutableMapping for headers (#6969) 2022-01-22 12:01:29 +02:00
Alex Waygood
96c9abb058 Always use _typeshed.Self, where applicable (#6880)
* Always use `_typeshed.Self`, where applicable

* Revert changes to `google-cloud-ndb` (ambiguous)

* Remove empty line added by script

* Revert changes to `stubs/python-dateutil/dateutil/relativedelta.pyi`

* Manually add a few more that the script missed

* Improve `filelock` annotation

Source code here: 79ec7b2826/src/filelock/_api.py (L207)

* Improve `opentracing/scope` annotation

Source code here: 3e1d357a34/opentracing/scope.py (L71)

* Improve `redis/client` stub

Source code here: 15f315a496/redis/client.py (L1217)

* Improve `redis/lock` annotation

Source code here: 15f315a496/redis/lock.py (L155)

* Improve `requests/models` annotation

Source code here: d718e75383/requests/models.py (L653)
2022-01-09 19:16:19 -08:00
Alex Waygood
a40d79a4e6 Use lowercase type everywhere (#6853) 2022-01-08 16:09:29 +01:00
cccs-jh
b2edc8fe4f Fix urllib.parse.ParseResultBytes.geturl() return type (#6846) 2022-01-07 00:57:25 +02:00
Alex Waygood
8d5d2520ac Use PEP 585 syntax wherever possible (#6717) 2021-12-28 11:31:43 +01:00
Anthony Sottile
60f2d2f86f improve urlencode(...) annotation for quote_via (#6345) 2021-12-20 18:30:35 -08:00
Akuli
994b69ef8f Use lowercase tuple where possible (#6170) 2021-10-14 17:18:19 -07:00
Anton Grübel
5f1adbfbd2 Add missing property in urllib.response, fix code types (#6108) 2021-10-04 16:01:33 -07:00
Akuli
ce11072dbe Big diff: use lower-case list and dict (#5888) 2021-08-08 09:26:35 -07:00
Akuli
ee487304d7 Big diff: Use new "|" union syntax (#5872) 2021-08-08 11:05:21 +02:00
Akuli
e3f662b648 switch to lower-case "# undocumented" comments (#5871) 2021-08-07 08:00:41 -07:00
Maarten ter Huurne
9bba8a4b83 Correct annotation of headers parameter of HTTP event handlers (#5854)
* Use HTTPMessage for the headers parameter of HTTP event handlers

While the documentation of `BaseHandler.http_error_default()` describes
the `hdrs` (`headers` in most other handlers) as "a mapping object with
the headers of the error", the implementation that is located in
`URLopener._open_generic_http()` will pass `response.msg` instead,
which is of type `http.client.HTTPMessage`.

* Use Message for the headers parameter of HTTPError

When the standard library constructs `HTTPError`, it will
pass an `http.client.HTTPMessage`, which is a subclass of
`email.message.Message`. Picking the superclass for the
annotations gives users the flexibility to for example
the result of the `email.message_from_X()` functions.

The only thing unique to `HTTPMessage` is the undocumented
`getallmatchingheaders()` method, which is only called by
`http.server.CGIHTTPRequestHandler.run_cgi()`. That class
gets its headers from `http.client.parse_headers()` and not
from `HTTPError`, so I think it's safe to use `Message`
as the annotation.
2021-08-06 10:55:49 +02:00
Unrud
2ee7b1346b Replace IO[str] with IO[bytes] in urllib.request (#5728) 2021-07-05 09:41:59 +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
Sebastian Rittau
f0bf6eebbd AnyStr cleanup (#5487)
* Replace all uses of StrPath, BytesPath, and AnyPath in Python 2 stubs.
* Add StrOrBytesPath as preferred alias for AnyPath.
* Replace all remaining AnyPath instances with StrOrBytesPath.
* Mark AnyPath as obsolete.

Part of #5470
2021-05-17 20:45:48 +02:00
Sebastian Rittau
e5abd08f93 Replace PathLike unions with aliases from _typeshed (#5467)
Standardize on 'from os import PathLike'
2021-05-16 21:38:00 +02:00
hatal175
b8e5f637b9 Stubtest fixes (#5391) 2021-05-13 18:20:55 -07:00
Mahmoud Harmouch
01ccf25d62 Add missing members for AbstractBasicAuthHandler class (#5379)
* Add missing members for AbstractBasicAuthHandler class

Signed-off-by: Harmouch101 <mahmoudddharmouchhh@gmail.com>

* Added missing functions to ftpwrapper

Signed-off-by: Harmouch101 <mahmoudddharmouchhh@gmail.com>
2021-05-09 11:18:24 +03:00
hatal175
2dc02ae8a9 Fix stubtest issues (#5360)
* Fix some stubtest issues

* Remove MADV_SOFT_OFFLINE
2021-05-07 19:10:03 +03:00