Eugene Toder
13d0c1fbcd
Make _MiddlewareFactory compatible with Callable ( #2768 )
2024-11-26 01:28:34 -06:00
Yurii Karabas
427a8dcf35
Fix issue with middleware args passing ( #2752 )
2024-11-14 17:34:22 -06:00
Marcelo Trylesinski
99b6938363
Allow to raise `HTTPException` before `websocket.accept()` ( #2725 )
...
* Allow to raise `HTTPException` before `websocket.accept()`
* move <<
* Add documentation
2024-10-15 09:50:49 +02:00
Marcelo Trylesinski
b9db010d49
Set `line-length` to 120 on Ruff ( #2679 )
...
* Set `line-length` to 120 on Ruff
* Add links to selected rules
* Remove empty strings
* Fix more stuff
2024-09-01 15:11:01 +02:00
Scirlat Danut
78fcd54c07
Create types module inside tests ( #2502 )
...
* Create types module inside tests
* Apply suggestions from code review
* Apply suggestions from code review
* Fix check errors
* Change testclientfactory due to autotest
* No cover fix
* Apply suggestions from code review
* Skip code coverage for TestClientFactory protocol
* Apply suggestions from code review
* Small improvements
* Lint
* Fix everything
---------
Co-authored-by: Scirlat Danut <scirlatdanut@scirlats-mini.lan>
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
2024-07-27 03:31:16 -06:00
dependabot[bot]
296cab922a
Bump the python-packages group with 13 updates ( #2632 )
...
* Bump the python-packages group with 13 updates
Bumps the python-packages group with 13 updates:
| Package | From | To |
| --- | --- | --- |
| [anyio](https://github.com/agronholm/anyio ) | `4.3.0` | `4.4.0` |
| [coverage](https://github.com/nedbat/coveragepy ) | `7.4.3` | `7.5.4` |
| [importlib-metadata](https://github.com/python/importlib_metadata ) | `7.0.1` | `8.0.0` |
| [mypy](https://github.com/python/mypy ) | `1.8.0` | `1.10.1` |
| [ruff](https://github.com/astral-sh/ruff ) | `0.1.15` | `0.5.0` |
| [typing-extensions](https://github.com/python/typing_extensions ) | `4.10.0` | `4.12.2` |
| [types-pyyaml](https://github.com/python/typeshed ) | `6.0.12.12` | `6.0.12.20240311` |
| [pytest](https://github.com/pytest-dev/pytest ) | `8.0.2` | `8.2.2` |
| [trio](https://github.com/python-trio/trio ) | `0.24.0` | `0.25.1` |
| [mkdocs](https://github.com/mkdocs/mkdocs ) | `1.5.3` | `1.6.0` |
| [mkdocs-material](https://github.com/squidfunk/mkdocs-material ) | `9.5.12` | `9.5.27` |
| [build](https://github.com/pypa/build ) | `1.1.1` | `1.2.1` |
| [twine](https://github.com/pypa/twine ) | `5.0.0` | `5.1.1` |
Updates `anyio` from 4.3.0 to 4.4.0
- [Release notes](https://github.com/agronholm/anyio/releases )
- [Changelog](https://github.com/agronholm/anyio/blob/master/docs/versionhistory.rst )
- [Commits](https://github.com/agronholm/anyio/compare/4.3.0...4.4.0 )
Updates `coverage` from 7.4.3 to 7.5.4
- [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.3...7.5.4 )
Updates `importlib-metadata` from 7.0.1 to 8.0.0
- [Release notes](https://github.com/python/importlib_metadata/releases )
- [Changelog](https://github.com/python/importlib_metadata/blob/main/NEWS.rst )
- [Commits](https://github.com/python/importlib_metadata/compare/v7.0.1...v8.0.0 )
Updates `mypy` from 1.8.0 to 1.10.1
- [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md )
- [Commits](https://github.com/python/mypy/compare/v1.8.0...v1.10.1 )
Updates `ruff` from 0.1.15 to 0.5.0
- [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.15...0.5.0 )
Updates `typing-extensions` from 4.10.0 to 4.12.2
- [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.10.0...4.12.2 )
Updates `types-pyyaml` from 6.0.12.12 to 6.0.12.20240311
- [Commits](https://github.com/python/typeshed/commits )
Updates `pytest` from 8.0.2 to 8.2.2
- [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/8.0.2...8.2.2 )
Updates `trio` from 0.24.0 to 0.25.1
- [Release notes](https://github.com/python-trio/trio/releases )
- [Commits](https://github.com/python-trio/trio/compare/v0.24.0...v0.25.1 )
Updates `mkdocs` from 1.5.3 to 1.6.0
- [Release notes](https://github.com/mkdocs/mkdocs/releases )
- [Commits](https://github.com/mkdocs/mkdocs/compare/1.5.3...1.6.0 )
Updates `mkdocs-material` from 9.5.12 to 9.5.27
- [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.12...9.5.27 )
Updates `build` from 1.1.1 to 1.2.1
- [Release notes](https://github.com/pypa/build/releases )
- [Changelog](https://github.com/pypa/build/blob/main/CHANGELOG.rst )
- [Commits](https://github.com/pypa/build/compare/1.1.1...1.2.1 )
Updates `twine` from 5.0.0 to 5.1.1
- [Release notes](https://github.com/pypa/twine/releases )
- [Changelog](https://github.com/pypa/twine/blob/main/docs/changelog.rst )
- [Commits](https://github.com/pypa/twine/compare/5.0.0...v5.1.1 )
---
updated-dependencies:
- dependency-name: anyio
dependency-type: direct:production
update-type: version-update:semver-minor
dependency-group: python-packages
- dependency-name: coverage
dependency-type: direct:production
update-type: version-update:semver-minor
dependency-group: python-packages
- dependency-name: importlib-metadata
dependency-type: direct:production
update-type: version-update:semver-major
dependency-group: python-packages
- 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-minor
dependency-group: python-packages
- dependency-name: typing-extensions
dependency-type: direct:production
update-type: version-update:semver-minor
dependency-group: python-packages
- dependency-name: types-pyyaml
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-minor
dependency-group: python-packages
- dependency-name: trio
dependency-type: direct:production
update-type: version-update:semver-minor
dependency-group: python-packages
- dependency-name: mkdocs
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-patch
dependency-group: python-packages
- dependency-name: build
dependency-type: direct:production
update-type: version-update:semver-minor
dependency-group: python-packages
- dependency-name: twine
dependency-type: direct:production
update-type: version-update:semver-minor
dependency-group: python-packages
...
Signed-off-by: dependabot[bot] <support@github.com>
* Add all changes needed for bump
* Ignore ResourceWarning
---------
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-07-27 03:03:46 -06:00
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
Paweł Rubin
866a15f79c
Add `*args` to `Middleware` and improve its type hints ( #2381 )
...
Co-authored-by: Paweł Rubin <pawel.rubin@ocado.com>
2023-12-20 22:09:17 +01:00
Adrian Garcia Badaracco
f640241b87
Fix typing of Lifespan to allow subclasses of Starlette ( #2077 )
...
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
2023-03-13 18:04:15 +00:00
Marcelo Trylesinski
cc20c8606e
Deprecate `on_startup` and `on_shutdown` events ( #2070 )
...
* Revert "Support lifespan state (#2060 )"
This reverts commit da6461b239
.
* new implementation
* Deprecate `on_startup` and `on_shutdown` events
* Rename `events.md` by `lifespan.md`
---------
Co-authored-by: Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com>
2023-03-09 23:30:28 +01:00
Adrian Garcia Badaracco
51c1de1839
Lazily build middleware stack ( #2017 )
...
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
2023-02-06 05:35:09 +00:00
Marcelo Trylesinski
fd1e91a8de
Deprecate `Starlette` and `Router` decorators ( #1897 )
2022-12-03 08:54:08 +01:00
Marcelo Trylesinski
d525431aad
Add `WebSocketException` and support for WS handlers ( #1263 )
...
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
Co-authored-by: Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com>
Co-authored-by: Tom Christie <tom@tomchristie.com>
2022-09-05 14:31:59 +02:00
Hugo van Kemenade
589df78616
Remove compat code for Python < 3.7 ( #1616 )
...
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
2022-05-01 22:03:41 +02:00
Amin Alaee
37f61dae8d
Remove routing decorators in `test_application.py` ( #1489 )
...
* Remove routing decorators in test_application.py
* Remove routing decorators in test_application.py
* Remove deprecated API usage in test_application.py
* Update starlette/applications.py
* revert debug property setter change
* Remove routing decorators in test_application.py
* Remove deprecated API usage in test_application.py
* Update starlette/applications.py
* revert debug property setter change
* add pragma nocover
Co-authored-by: Tom Christie <tom@tomchristie.com>
2022-02-10 10:37:04 +00:00
Thomas Grainger
537ab6afd1
use an async context manager factory for lifespan ( #1227 )
2021-07-03 18:43:24 +01:00
Thomas Grainger
d222b87cb4
TestClient accepts backend and backend_options as arguments to constructor ( #1211 )
...
as opposed to ClassVar assignment
Co-authored-by: Jamie Hewland <jhewland@gmail.com>
Co-authored-by: Jordan Speicher <jordan@jspeicher.com>
Co-authored-by: Jordan Speicher <uSpike@users.noreply.github.com>
2021-06-28 21:36:13 +01:00
Tom Christie
152a05ac3d
Support generator function to manage startup/shutdown. ( #799 )
...
* Refactor lifespan to run as an async generator
* Add 'lifespan' argument
* Add 'app' argument to lifespan handler function
* Support either sync or async generators as the app 'lifespan' callable
2020-05-04 11:31:54 +01:00
Daniel Hahler
e0e2621add
flake8 fixes ( #512 )
2019-05-13 15:22:59 +01:00
Tom Christie
84f3488f60
Routing for Hosts and Subdomains ( #363 )
...
* Routing for Hosts and Subdomains
* Linting
2019-01-30 15:15:59 +00:00
Taoufik
0c3a1e4a60
f-strings everywhere ( #334 )
...
* f-strings everywhere
2019-01-22 16:24:46 +00:00
Tom Christie
93a124805f
Drop body from responses on HEAD requests ( #317 )
...
* Drop body from responses on HEAD requests
* Linting
* Endpoints supporting HEAD should automatically support GET
2019-01-14 11:07:23 +00:00
Tom Christie
632150d73e
Lifespan as middleware ( #225 )
...
* Lifespan as middleware
* 3.6 compat
* Add annotations
* Handle exceptions from applications within LifespanMiddleware
* Lifespan moves to middleware. TestClient can be used as a context manager.
2018-11-28 11:51:17 +00:00
Tom Christie
9f3dcb7d2b
Rejig ExceptionMiddleware and ServerErrorMiddleware ( #193 )
...
* Rejig ExceptionMiddleware and ServerErrorMiddleware
* Tweak DebugMiddleware implementation
* Support custom 500 handlers
* Exception handling updates
2018-11-08 11:59:15 +00:00
Tom Christie
bcf876c686
Use isort for consistent import ordering ( #156 )
2018-10-29 14:46:42 +00:00
Tom Christie
c047fe4e75
Support app.url_path_for and request.url_for ( #153 )
2018-10-29 11:14:42 +00:00
Tom Christie
8da0f00fe7
Routing interface ( #144 )
...
* Path -> Route, PathPrefix -> Mount
* Route, WebSocketRoute, Mount
* Use Route(endpoint=...), not Route(app=...)
* Bare minimum docs update
* Add url_for
* request.path_params and session.path_params
* Version 0.6.0
2018-10-29 09:22:45 +00:00
Alexander Botello
3ca34ce0a2
Support a routing interface for `Router` ( #143 )
...
* Add a routing interface to Router
* Starlette class now wraps routing functionality from Router
* No need to pass in empty list
* Add missing test coverage
* black that one file i always forget
2018-10-26 10:30:54 +01:00
Alexander Botello
bc26ab3319
Support either `cleanup` or `shutdown` in ASGI lifespan messages ( #134 )
...
* support either cleanup or shutdown in ASGI message
* change event_type in tests
* update docs
* fix typo
* keep as event_type for now
* exclude line 65
* blackify
* replace cleanup with shutdown in docs
2018-10-22 15:08:04 +01:00
Alexander Botello
b0763469ff
Support a function-based interface for adding events on LifespanHandler ( #124 )
...
* Add function interface to lifespanhandler
* function interface accessible added to applications
* Add test for add_event_handler
2018-10-18 08:43:21 +01:00
Tom Christie
6dd6dd6f0a
Add scope=... arguments to Headers, QueryParams, URL ( #118 )
2018-10-17 12:31:53 +01:00
Tom Christie
c50460fbb9
Add final missing annotations, and enable '--disallow-untyped-defs' ( #115 )
...
* fix(dataStructures): missing annotations added
* fix(requests.py): annotations added
* fix(Annotations): wrong annotations fixed on datastructures and requests modules.
* fix(Missing annotation): missing annotations added on testclient module.
* fix(testclient): annotations fixed
* minor tweaks
* fix(testclient): Session request method fixed. WIP _ASGIAdapter send method
* fix(testclient): small tweaks
* Switch on --disallow-untyped-defs when testing with mypy
2018-10-16 15:56:28 +01:00
Tom Christie
19670ae2cd
Middleware ( #82 )
...
* Tweaks to URL datastructure
* Linting
* Add Middleware
2018-10-05 12:04:11 +01:00
Tom Christie
78d1829758
Version 0.3 ( #57 )
...
* Renamings
* Version 0.3.0
* Black formatting
* Update docs for 0.3
2018-09-05 11:39:38 +01:00