Commit Graph

1308 Commits

Author SHA1 Message Date
Scirlat Danut 11b7ae7365
Add type hints to `test_applications.py` (#2471)
* added type annotations to test_applications.py

* requested changes

* Apply suggestions from code review

* Apply suggestions from code review

* Update tests/test_applications.py

---------

Co-authored-by: Scirlat Danut <scirlatdanut@scirlats-mini.lan>
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
2024-02-06 20:30:47 +00:00
Scirlat Danut 8c222960ba
Add type hints to `test_requests.py` (#2481)
* added type annotations to test_requests.py

* requested changes

* indentations

* typos

* typos

* Apply suggestions from code review

* Apply suggestions from code review

---------

Co-authored-by: Scirlat Danut <scirlatdanut@scirlats-mini.lan>
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
2024-02-06 13:18:43 -07:00
Scirlat Danut ee3cdfd5dc
Add type hints to `test_gzip.py` (#2464)
* added type annotations to test_gzip.py

* Apply suggestions from code review

* Apply suggestions from code review

---------

Co-authored-by: Scirlat Danut <scirlatdanut@scirlats-mini.lan>
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
2024-02-05 10:46:34 +00:00
Marcelo Trylesinski 6fcd579648
Version 0.37.0 (#2457) 2024-02-04 23:54:55 -07:00
Scirlat Danut 52531565cc
Added type annotations to test_endpoints.py (#2478)
* added type annotations to test_endpoints.py

* Apply suggestions from code review

---------

Co-authored-by: Scirlat Danut <scirlatdanut@scirlats-mini.lan>
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
2024-02-04 14:06:00 -07:00
Scirlat Danut c158ef45be
Added type annotations to test_error.py (#2462)
* added type annotations to test_error.py

* Apply suggestions from code review

---------

Co-authored-by: Scirlat Danut <scirlatdanut@scirlats-mini.lan>
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
2024-02-04 20:54:16 +00:00
Kristján Valur Jónsson 93e74a4d2f
Support the WebSocket Denial Response ASGI extension (#2041)
* supply asgi_extensions to TestClient

* Add WebSocket.send_response()

* Add response support for WebSocket testclient

* fix test for filesystem line-endings

* lintint

* support websocket.http.response extension by default

* Improve coverate

* Apply suggestions from code review

Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>

* Undo unrelated change

* fix incorrect error message

* Update starlette/websockets.py

Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>

* formatting

* Re-introduce close-code and close-reason to WebSocketReject

* Make sure the "websocket.connect" message is received in tests

* Deliver a websocket.disconnect message to the app even if it closes/rejects itself.

* Add test for filling out missing `websocket.disconnect` code

* Add rejection headers.  Expand tests.

* Fix types, headers in message are `bytes` tuples.

* Minimal WebSocket Denial Response implementation

* Revert "Minimal WebSocket Denial Response implementation"

This reverts commit 7af10ddcfa5423c18953cf5d1317cb5aa30a014c.

* Rename to send_denial_response and update documentation

* Remove the app_disconnect_msg.  This can be added later in a separate PR

* Remove status code 1005 from this PR

* Assume that the application has tested for the extension before sending websocket.http.response.start

* Rename WebSocketReject to WebSocketDenialResponse

* Remove code and status from WebSocketDenialResponse.
Just send a regular WebSocketDisconnect even when connection is rejected with close()

* Raise an exception if attempting to send a http response and server does not support it.

* WebSocketDenialClose and WebSocketDenialResponse
These are both instances of WebSocketDenial.

* Update starlette/testclient.py

Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>

* Revert "WebSocketDenialClose and WebSocketDenialResponse"

This reverts commit 71b76e3f1c.

* Rename parameters, member variables

* Use httpx.Response as the base for WebSocketDenialResponse.

* Apply suggestions from code review

Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>

* Update sanity check message

* Remove un-needed function

* Expand error message test regex

* Add type hings to test methods

* Add doc string to test.

* Fix mypy complaining about mismatching parent methods.

* nitpick & remove test

* Simplify the documentation

* Update starlette/testclient.py

* Update starlette/testclient.py

* Remove an unnecessary test

* there is no special "close because of rejection" in the testclient anymore.

---------

Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
2024-02-04 20:16:10 +00:00
Scirlat Danut 043c800210
Added type annotations to test_convertors.py (#2476)
* added type annotations to test_convertors.py

* Apply suggestions from code review

---------

Co-authored-by: Scirlat Danut <scirlatdanut@scirlats-mini.lan>
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
2024-02-04 18:39:34 +00:00
Scirlat Danut 551bf867d2
Added type annotations to test_config.py (#2475)
* added type annotations to test_config.py

* Apply suggestions from code review

---------

Co-authored-by: Scirlat Danut <scirlatdanut@scirlats-mini.lan>
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
2024-02-04 18:33:06 +00:00
Scirlat Danut 5ab70d8fdf
added type annotations to test_http_redirect.py (#2465)
Co-authored-by: Scirlat Danut <scirlatdanut@scirlats-mini.lan>
2024-02-04 18:30:43 +00:00
Scirlat Danut b817dc4d61
Added type annotations to test_datastructures.py (#2477)
Co-authored-by: Scirlat Danut <scirlatdanut@scirlats-mini.lan>
2024-02-04 18:27:43 +00:00
Scirlat Danut fce2809f99
Added type annotations to test_exceptions.py (#2479)
Co-authored-by: Scirlat Danut <scirlatdanut@scirlats-mini.lan>
2024-02-04 18:21:41 +00:00
Marcelo Trylesinski be4f3e110e
Version 0.36.3 (#2460) 2024-02-04 18:15:10 +00:00
Scirlat Danut a2f2dda8d7
Added type annotations to test_session.py (#2466)
Co-authored-by: Scirlat Danut <scirlatdanut@scirlats-mini.lan>
2024-02-04 17:58:54 +00:00
Scirlat Danut 801e73e4d1
Add type hints to `test_concurency.py` (#2474)
Co-authored-by: Scirlat Danut <scirlatdanut@scirlats-mini.lan>
2024-02-04 17:15:40 +00:00
Scirlat Danut 88331bd5f8
Add type hints to `conftest.py` (#2469)
Co-authored-by: Scirlat Danut <scirlatdanut@scirlats-mini.lan>
2024-02-04 10:13:09 -07:00
Scirlat Danut 5acee62377
Added type annotations to test__utils.py (#2470)
* added type annotations to test__utils.py

* ignore functools.partial sync type

* ruff fix

* typo

* type ignore

---------

Co-authored-by: Scirlat Danut <scirlatdanut@scirlats-mini.lan>
2024-02-04 16:50:59 +00:00
Scirlat Danut 48ae5ccc0e
Add type hints to `test_background.py` (#2473)
Co-authored-by: Scirlat Danut <scirlatdanut@scirlats-mini.lan>
2024-02-04 16:48:26 +00:00
Scirlat Danut adf51ea75d
Add type hints to `test_trusted_host.py` (#2467)
Co-authored-by: Scirlat Danut <scirlatdanut@scirlats-mini.lan>
2024-02-04 15:13:48 +00:00
Scirlat Danut 1f466cce11
Add type hints to `test_wsgi.py` (#2468)
Co-authored-by: Scirlat Danut <scirlatdanut@scirlats-mini.lan>
2024-02-04 08:11:13 -07:00
Marcelo Trylesinski ec417f7f84
Create `anyio.Event` on async context (#2459)
* Create `anyio.Event` using a blocking portal

* Use cached property

* Ups
2024-02-04 05:50:31 -07:00
Scirlat Danut a9af536a07
Add type hints to `test_cors.py` (#2458)
Co-authored-by: Scirlat Danut <scirlatdanut@scirlats-mini.lan>
2024-02-03 13:51:19 -07:00
Scirlat Danut 3434c3d990
Add type hints to `test_base.py` (#2445)
* added type annotations to test-base.py

* deleted unused imports

* fixed import order

* conditional import

* conditional import TestClient on types.py

* using string literals when importing in types

* added missing imports

* deleted starlette/types, refactored test_base types

* deleted types

---------

Co-authored-by: Scirlat Danut <scirlatdanut@scirlats-mini.lan>
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
2024-02-03 09:54:21 -07:00
Marcelo Trylesinski 04a7d9d8d1
Version 0.36.2 (#2456)
* Version 0.36.2

* Apply suggestions from code review

* Update docs/release-notes.md
2024-02-03 12:39:24 +00:00
Sebastián Ramírez 13e5c26a27
Merge pull request from GHSA-93gm-qmq6-w238 2024-02-03 05:34:10 -07:00
Mikkel Duif b8eebef387
Avoid duplicate charset on `Content-Type` (#2443)
* fix(response): avoid duplicated charset

* Update docs/responses.md

---------

Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
2024-02-03 08:39:01 +00:00
dependabot[bot] 8da52c2243
Bump the python-packages group with 4 updates (#2455)
* Bump the python-packages group with 4 updates

Bumps the python-packages group with 4 updates: [coverage](https://github.com/nedbat/coveragepy), [ruff](https://github.com/astral-sh/ruff), [pytest](https://github.com/pytest-dev/pytest) and [mkdocs-material](https://github.com/squidfunk/mkdocs-material).


Updates `coverage` from 7.4.0 to 7.4.1
- [Release notes](https://github.com/nedbat/coveragepy/releases)
- [Changelog](https://github.com/nedbat/coveragepy/blob/master/CHANGES.rst)
- [Commits](https://github.com/nedbat/coveragepy/compare/7.4.0...7.4.1)

Updates `ruff` from 0.1.13 to 0.1.15
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](https://github.com/astral-sh/ruff/compare/v0.1.13...v0.1.15)

Updates `pytest` from 7.4.4 to 8.0.0
- [Release notes](https://github.com/pytest-dev/pytest/releases)
- [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest/compare/7.4.4...8.0.0)

Updates `mkdocs-material` from 9.5.5 to 9.5.6
- [Release notes](https://github.com/squidfunk/mkdocs-material/releases)
- [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG)
- [Commits](https://github.com/squidfunk/mkdocs-material/compare/9.5.5...9.5.6)

---
updated-dependencies:
- dependency-name: coverage
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: python-packages
- dependency-name: ruff
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: python-packages
- dependency-name: pytest
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: python-packages
- dependency-name: mkdocs-material
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: python-packages
...

Signed-off-by: dependabot[bot] <support@github.com>

* add deprecation warning

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
2024-02-03 08:01:51 +00:00
François Voron 4355e6bc28
Fix nav override for newer version of Mkdocs Material (#2444) 2024-01-26 12:32:55 +00:00
Marcelo Trylesinski 433da65fc1
Version 0.36.1 (#2440) 2024-01-23 08:31:18 +00:00
Marcelo Trylesinski 4ca0a8757a
Downgrade mkdocs-material (#2439) 2024-01-23 01:29:01 -07:00
Marcelo Trylesinski e54be85aba
Check if "extensions" in scope before checking the extension (#2438) 2024-01-23 08:42:18 +01:00
Marcelo Trylesinski 8d09cf4b69
Version 0.36.0 (#2432)
* Version 0.36.0

* Update release-notes.md
2024-01-22 20:36:10 +00:00
Giovanni Barillari 7936e86f0a
Add support for ASGI `pathsend` extension (#2435)
* add support for ASGI `pathsend` extension

* add test for ASGI `pathsend`
2024-01-22 02:44:40 -07:00
Marcelo Trylesinski 6bfe9fea04
Use `__future__.annotations` (#2433)
* Use `__future__.annotations`

* fix linter
2024-01-20 18:57:59 +01:00
Marcelo Trylesinski b5126b2063
Raise `WebSocketDisconnect` when `WebSocket.send()` excepts `IOError` (#2425)
* Raise `WebSocketDisconnect` when `WebSocket.send()` excepts `IOError`

* Restrict the IOError
2024-01-20 08:08:22 -07:00
Marcelo Trylesinski 3ae161ed8f
Cancel `WebSocketTestSession` on close (#2427)
* Cancel `WebSocketTestSession` on close

* Undo some noise

* Fix test

* Undo pyproject

* Undo anyio bump

* Undo changes on test_authentication

* Always call cancel scope
2024-01-20 06:59:47 -07:00
Mathias Hauser 13c66c9294
Raise `FileNotFoundError` when the `env_file` parameter on `Config` is not valid (#2422)
* raise error on missing env file

* format

---------

Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
2024-01-20 12:06:50 +00:00
Marcelo Trylesinski d2d9192966
Add PyPI versions supported (#2431) 2024-01-20 03:43:45 -07:00
dependabot[bot] 363e4fb194
Bump the python-packages group with 5 updates (#2418)
Bumps the python-packages group with 5 updates:

| Package | From | To |
| --- | --- | --- |
| [mypy](https://github.com/python/mypy) | `1.7.1` | `1.8.0` |
| [ruff](https://github.com/astral-sh/ruff) | `0.1.9` | `0.1.13` |
| [pytest](https://github.com/pytest-dev/pytest) | `7.4.0` | `7.4.4` |
| [trio](https://github.com/python-trio/trio) | `0.23.2` | `0.24.0` |
| [mkdocs-material](https://github.com/squidfunk/mkdocs-material) | `9.1.17` | `9.5.3` |


Updates `mypy` from 1.7.1 to 1.8.0
- [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md)
- [Commits](https://github.com/python/mypy/compare/v1.7.1...v1.8.0)

Updates `ruff` from 0.1.9 to 0.1.13
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](https://github.com/astral-sh/ruff/compare/v0.1.9...v0.1.13)

Updates `pytest` from 7.4.0 to 7.4.4
- [Release notes](https://github.com/pytest-dev/pytest/releases)
- [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest/compare/7.4.0...7.4.4)

Updates `trio` from 0.23.2 to 0.24.0
- [Release notes](https://github.com/python-trio/trio/releases)
- [Commits](https://github.com/python-trio/trio/compare/v0.23.2...v0.24.0)

Updates `mkdocs-material` from 9.1.17 to 9.5.3
- [Release notes](https://github.com/squidfunk/mkdocs-material/releases)
- [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG)
- [Commits](https://github.com/squidfunk/mkdocs-material/compare/9.1.17...9.5.3)

---
updated-dependencies:
- dependency-name: mypy
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: python-packages
- dependency-name: ruff
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: python-packages
- dependency-name: pytest
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: python-packages
- dependency-name: trio
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: python-packages
- dependency-name: mkdocs-material
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: python-packages
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-13 04:02:01 -07:00
Marcelo Trylesinski 53808c4b26
Group dependencies on dependabot updates (#2415) 2024-01-13 18:48:51 +08:00
Marcelo Trylesinski 8d7630bda1
Add type hint on `test_websockets.py` (#2411)
* Add type hint on `test_websockets.py`

* Add type ignore on mock_receive
2024-01-12 03:06:48 -07:00
Marcelo Trylesinski c8176050aa
Version 0.35.1 (#2410) 2024-01-11 19:57:49 +00:00
Marcelo Trylesinski 6c4ffeee01
Make `typing-extensions` optional again (#2409) 2024-01-11 12:55:30 -07:00
Sebastián Ramírez 3734e85c18
♻️ Do not use the deprecated `method` parameter in `FileResponse` inside of `StaticFiles` (#2406)
* ♻️ Do not use the deprecated `method` parameter in `FileResponse` inside of` StaticFile`

*  Add test for warning FileResponse with method argument

* 🔊 Remove warning filter for FileResponse with method
2024-01-11 08:17:18 -07:00
Marcelo Trylesinski 1081520b75
Version 0.35.0 (#2404)
* Version 0.35.0

* Update release-notes.md
2024-01-11 07:29:36 -07:00
Sebastián Ramírez c3c6314759
♻️ Refactor logic to handle `root_path` to keep compatibility with ASGI and compatibility with other non-Starlette-specific libraries like a2wsgi (#2400)
*  Add util to get route path from scope

* ♻️ Refactor extracting the local route_path from the scope, and creating the child scope with its own root_pat, this allows sub-apps (e.g. WSGIMiddleware) to know
where it was mounted, and from which path prefix starts the path its sub-app should handle

* ♻️ Refactor datastructures and request to be conformant with the ASGI spec, respecting root_path

*  Add and update tests for root_path with mounted apps that don't know about Starlette internals (e.g. the route_root_path extension scope key that was added in

*  Update test for root_path, TestClient was not requiring paths under a root_path to pass the root_path, which is what clients would have to do if the app is
mounted.

* 🎨 Fix formatting

* 🎨 Remove type ignore

* 🔥 Remove unnecessary comment

*  Update (deprecated) WSGIMiddleware to be compatible with the updated root_path, taking pieces from a2wsgi

* 🎨 Fix types

*  Update test for WSGIMiddleware with root_path

* 🔥 Remove logic/features not in the original (deprecated) WSGIMiddleware

---------

Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
Co-authored-by: Aber <me@abersheeran.com>
2024-01-09 12:45:30 +08:00
dependabot[bot] 8f2307d31f
Bump trio from 0.22.2 to 0.23.2 (#2395)
* Bump trio from 0.22.2 to 0.23.2

Bumps [trio](https://github.com/python-trio/trio) from 0.22.2 to 0.23.2.
- [Release notes](https://github.com/python-trio/trio/releases)
- [Commits](https://github.com/python-trio/trio/compare/v0.22.2...v0.23.2)

---
updated-dependencies:
- dependency-name: trio
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Remove AnyIO from requirements.txt

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
2024-01-08 21:26:34 +00:00
dependabot[bot] d28d491a34
Bump ruff from 0.1.6 to 0.1.9 (#2396)
* Bump ruff from 0.1.6 to 0.1.9

Bumps [ruff](https://github.com/astral-sh/ruff) from 0.1.6 to 0.1.9.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](https://github.com/astral-sh/ruff/compare/v0.1.6...v0.1.9)

---
updated-dependencies:
- dependency-name: ruff
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix code

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
2024-01-08 08:49:23 +00:00
dependabot[bot] 5f9da0b656
Bump coverage from 7.3.2 to 7.4.0 (#2397) 2024-01-01 21:36:25 +01:00
dependabot[bot] 04684c22e8
Bump typing-extensions from 4.8.0 to 4.9.0 (#2393)
Bumps [typing-extensions](https://github.com/python/typing_extensions) from 4.8.0 to 4.9.0.
- [Release notes](https://github.com/python/typing_extensions/releases)
- [Changelog](https://github.com/python/typing_extensions/blob/main/CHANGELOG.md)
- [Commits](https://github.com/python/typing_extensions/compare/4.8.0...4.9.0)

---
updated-dependencies:
- dependency-name: typing-extensions
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-01 13:18:57 -07:00