Commit Graph

96 Commits

Author SHA1 Message Date
Alex Waygood
b69b17c3d8 Add defaults for third-party stubs Q-T (#9959) 2023-03-28 13:16:31 +02:00
Adam Dangoor
19368ab964 Add type to requests.models.RequestEncodingMixin.path_url (#9923)
We can see at 7f694b79e1/requests/models.py (L104) that this always returns a string.
2023-03-22 19:20:40 +00:00
Avasam
52ec44fa58 Improve many __(a)exit__ annotations (#9696) 2023-02-25 21:50:30 +00:00
Avasam
ed6748fb32 Stubtest settings: change ignore_missing_stub default to false (#9779)
If you're reading about this commit from an autogenerated changelog entry, this should have no user-visible impact on how the stubs are interpreted by a type checker; it's just an internal change to how typeshed's tests work.
2023-02-20 22:37:45 +00:00
Alex Waygood
7180d0223b Use typing_extensions.Self instead of _typeshed.Self (#9702) 2023-02-15 11:32:43 +01:00
Alex Waygood
60789273a2 Improve pyright verification of third-party test cases in CI (#9650)
Co-authored-by: Avasam <samuel.06@hotmail.com>
2023-02-07 11:53:54 +00:00
Alex Waygood
0ef9c3f8e8 Enable flake8-pyi's Y037 (#9686) 2023-02-06 19:01:02 -08:00
Alex Waygood
efee70abfa Bump mypy to 1.0 (#9684) 2023-02-06 15:57:17 -08:00
Nikita Sobolev
f7cb7f33b2 Use OSError instead of IOError (#9683) 2023-02-06 18:56:32 +00:00
Alex Waygood
4fea314594 Replace Any with Incomplete in many places (#9558) 2023-01-18 08:48:16 +00:00
Eugene Vilensky
6a7839f2c5 requests: set session.headers to MutableMapping (#9395) 2022-12-22 15:02:58 +00:00
Mauricio Villegas
1b50eb09df requests: types for auth username and password (#9389) 2022-12-20 16:34:40 -06:00
Nikita Sobolev
c6261372d7 Always use bool and Literal for Python compat code (#9213) 2022-11-16 18:00:59 +00:00
Nikita Sobolev
62a6c3d616 Annotate known magic-method return types (#9131) 2022-11-08 18:28:42 +00:00
Nikita Sobolev
c0e9038f0d Fix and allow classes with missing metaclasses (#9136) 2022-11-08 18:13:59 +00:00
Samuel T
573ee94f35 All scripts/tests: always specify file encoding in calls to open() (#8882) 2022-10-11 22:29:36 +01:00
Alex Waygood
e173cbe7b6 Mark requests stubs as complete (#8858)
Co-authored-by: Kevin Kirsche <kevin.kirsche@one.verizon.com>
2022-10-06 15:31:02 -07:00
Alex Waygood
f9b1289226 requests: Add regression test for #8762 (#8835)
The final mypy_primer report for #8762 was an empty diff. Considering the number of issues we've had with our requests stubs over the last year, it feels like it makes sense to add a test case to make sure that it doesn't regress.
2022-10-03 16:11:44 -07:00
Rogdham
b3db49abbd requests: improve _Data type (#8762)
requests: improve _Data type

This allows to pass an Iterable[bytes] for streaming request data.
2022-09-21 16:35:09 -07:00
Alex Waygood
b53843ab46 Add infrastructure allowing for test cases for third-party stubs (#8700)
- Move the logic for running mypy on the test cases from `tests/mypy_test.py` to a separate script, `tests/regr_test.py`.
- Add the necessary logic in order to be able to have test cases for third-party stubs.
- Move logic common to `tests/mypy_test.py` and `tests/regr_test.py` into `tests/colors.py`, and rename `tests/colors.py` to `tests/utils.py`.
- Add a new check to `tests/check_consistent.py`, to enforce the use of `# pyright: reportUnnecessaryTypeIgnoreComment=true` comments in third-party test cases. These are essential if we want to have our tests against false-negatives work with pyright.
- Update the relevant documentation to account for the new test file.
- Add a new job to the `tests.yml` GitHub workflow, to run the new test in CI.
- Add a simple proof-of-concept test case for `requests`, as a regression test for #7998.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
2022-09-08 16:51:33 +01:00
Kevin Kirsche
8c51fab4e2 Support extras in stubtest_third_party.py (#8467) 2022-08-18 14:12:36 -07:00
Kevin Kirsche
3e88363b34 requests.adapters: use re-exports rather than assignments (#8485) 2022-08-05 12:46:07 +01:00
Kevin Kirsche
68f20a4a23 Add requests.help submodule (#8486) 2022-08-05 12:32:40 +01:00
Kevin Kirsche
46a3806312 Add requests.__version__; improve requests.__init__ (#8484)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2022-08-05 12:28:35 +01:00
Shantanu
402489b40a requests: fix stubtest (#8463) 2022-08-01 18:39:06 -07:00
Alex Waygood
fdeb216547 Remove or move several TypeAlias declarations (#8444) 2022-07-30 15:28:52 +01:00
Kevin Kirsche
33878a6ea4 requests: add type hints to requests.utils (#8395)
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2022-07-26 06:25:56 -07:00
Kevin Kirsche
432e55b039 Add missing re-exports and vars to requests.compat (#8396) 2022-07-25 21:56:05 +01:00
John Villalovos
e42c983740 requests: add annotation for parse_header_links (#8349)
In the requests package the function `utils.parse_header_links()`
takes a str as input and returns a list of dictionaries.

This can be seen in the unit tests that are used:
786255613b/tests/test_utils.py (L644-L664)
2022-07-20 21:02:29 -07:00
David Hotham
6873a78b6b requests: Annotate Session.merge_environment_settings (#8313)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2022-07-18 19:54:48 +01:00
Sebastian Rittau
a0f6fb5669 Turn requests.requests.packages into a module (#8281)
Remove obsolete class VendorAlias
2022-07-12 20:30:28 +02:00
Shantanu
4415e9cc0b [stubsabot] Bump requests to 2.28.* (#8152)
Co-authored-by: hauntsaninja <>
2022-06-25 12:01:22 +05:30
Alex Waygood
3fe1f5d6c4 requests, regex: use re-exports instead of assignments in a few places (#8127) 2022-06-21 08:20:13 -07:00
Tom Milligan
51f97dda15 requests: expand types for files (#7999) 2022-06-01 22:55:38 +03:00
Alex Waygood
fa636bc044 Third-party stubs: fix several fictitious type aliases (#7958) 2022-05-26 06:26:26 -07:00
Akuli
f77d0f80a8 requests: allow immutable headers (#7932) 2022-05-25 20:22:05 -07:00
Akuli
9a09db46f5 Fix requests.Session().hooks (#7871)
Fixes #7776

Mutating hooks, as in `session.hooks['response'] = ...`, should work. Reassigning it like `session.hooks = ...` is probably a bad idea, so it will always be a `dict`.
2022-05-18 19:31:34 -07:00
Alejandro Giacometti
87abd8a39f requests: Fix type of request headers (#7773)
Allow bytes values. In `Session` methods, `None` can be used to ignore the session's headers.
2022-05-16 23:33:46 +03:00
Akuli
e613fc483b Delete python 2 branches from third-party stubs (#7741)
Since #7703, we no longer have third-party stubs that support Python 2, so code like `if sys.version_info >= (3, 0)` can be simplified.
2022-04-29 20:53:01 +01:00
Milan Boers
f330e12f3e requests: allow non-mutable Mapping for files/hooks parameters (#7732) 2022-04-28 08:40:53 -06:00
Milan Boers
df06044ee8 requests: allow str and bytes for fileobj in files parameter (#7728)
* requests: allow str and bytes for fileobj in files parameter

* requests: Use SupportsRead instead of IO for files
2022-04-28 02:19:57 -06:00
Alec Rosenbaum
63fb9af743 requests: Add None to a type alias (#7721)
Fixes #7720
2022-04-27 08:39:15 -06:00
Milan Boers
ae09e4e866 Add more typing hints for requests (#7696)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Akuli <akuviljanen17@gmail.com>
2022-04-27 14:40:20 +03:00
Alex Waygood
b093c90a94 Use TypeAlias for type aliases where possible, part II (#7667) 2022-04-20 20:02:47 +01:00
Alex Waygood
653f2c6ba4 Third-party stubs: import from collections.abc where possible (#7637) 2022-04-16 14:52:57 +01:00
Alex Waygood
66bea8ca48 Use imports instead of TypeAliases in a couple places (#7634)
Fixes #7632
2022-04-16 01:38:59 -07:00
Alex Waygood
740193a8fc Use TypeAlias where possible for type aliases (#7630) 2022-04-15 18:01:00 -07:00
Alex Waygood
c0e6dd3f3f Use str instead of typing.Text (#7629) 2022-04-16 00:47:42 +02:00
Alex Waygood
ec27c00ca2 Third-party stubs: Improve several __exit__ methods (#7575) 2022-04-01 08:03:12 -07:00
Kalle Møller
9aa64fdc22 requests: Update adapters.pyi (#7544)
The cert can be
* A string / bytes which is a path to a certfile
* A tuple with two string / bytes, where the first is the certfile and the second is a keyfile
* None (optional)

The tuple could be anything indexable, but there are strict requirement to actualle have two items, don't know if there is something more generic

See https://github.com/psf/requests/blob/main/requests/adapters.py#L242-L248
2022-03-26 20:41:25 -07:00