Skip to content

Commit

Permalink
Enhancement: Replace Starlette Responses (#626)
Browse files Browse the repository at this point in the history
* initial

* updated folder structure

* add file response

* added tests

* add anyio

* cleanup tests

* cleanup

* finished test coverage

* added docstrings

* updated reference docs

* updated docs

* Update docs/usage/16-templating/2-template-functions.md

Co-authored-by: Peter Schutt <[email protected]>

* Update starlite/response/base.py

Co-authored-by: Peter Schutt <[email protected]>

* addressed review comments

* cleanup imports

* updated response containers

* addressed review comment

* updated response containers missing args

* updated tests

* fix bound variable

* fixed typing

* fix bound variable

* removed constraint

* update docstrings

* update coverage

* Update ASGI router (#644)

* removed starlette dependency for lifespan events

* updated tests

* fix async callable

* added cookie parser (#645)

* added cookie parser

* address review comments

* Replace get name (#646)

* add get_name helper

* added helper to handle enum

* update enum safeguard

* Removed starlette HTTPException as code dependency (#647)

* removed starlette HTTPException as code dependency

* address review comments

* Replace background tasks (#652)

* updated background tasks

* updated test and docs

* address review comment

* fix lgtm issues and cleanup

* addressed review comments

* updated tests

Co-authored-by: Peter Schutt <[email protected]>
  • Loading branch information
Goldziher and peterschutt authored Oct 23, 2022
1 parent e58dd11 commit 0949b14
Show file tree
Hide file tree
Showing 167 changed files with 3,335 additions and 1,421 deletions.
7 changes: 4 additions & 3 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
[flake8]
max-line-length = 120
max-complexity = 12
ignore = E501, B008, W503, C408, B009, B023, C417, PT006, PT007, PT004, PT012, SIM401, E225, E203, SCS108
ignore = E501,E225,W503,B008,E203
type-checking-pydantic-enabled = true
type-checking-fastapi-enabled = true
classmethod-decorators =
classmethod
validator
root_validator
per-file-ignores =
examples/dependency_injection/dependency_non_optional_not_provided.py:E800
starlite/types/builtin_types.py:E800,F401
examples/*:SCS108
starlite/types/builtin_types.py:F401
tests/*:SCS108
55 changes: 43 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ repos:
hooks:
- id: blacken-docs
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.0.0-alpha.2"
rev: "v3.0.0-alpha.3"
hooks:
- id: prettier
exclude: docs
Expand Down Expand Up @@ -70,12 +70,10 @@ repos:
"flake8-print",
"flake8-simplify",
"flake8-type-checking",
"flake8-pytest-style",
"flake8-implicit-str-concat",
"flake8-noqa",
"flake8-return",
"flake8-secure-coding-standard",
"flake8-eradicate",
"flake8-encodings",
"flake8-use-fstring",
"flake8-use-pathlib",
Expand All @@ -85,22 +83,39 @@ repos:
hooks:
- id: flake8-markdown
- repo: https://github.com/dosisod/refurb
rev: v1.3.0
rev: v1.4.0
hooks:
- id: refurb
args: [--ignore, "120", --ignore, "128"]
additional_dependencies:
[
aiomcache,
beautifulsoup4,
brotli,
cryptography,
freezegun,
httpx,
hypothesis,
mako,
orjson,
piccolo,
picologging,
pydantic,
pydantic_factories,
pydantic_openapi_schema,
pytest,
pyyaml,
redis,
sqlalchemy,
sqlalchemy2-stubs,
starlette,
starlite_multipart,
structlog,
tortoise-orm,
types-PyYAML,
types-beautifulsoup4,
types-freezegun,
types-redis,
]
- repo: https://github.com/ariebovenberg/slotscheck
rev: v0.14.1
Expand Down Expand Up @@ -131,7 +146,7 @@ repos:
aiomcache,
]
- repo: https://github.com/pycqa/pylint
rev: "v2.15.4"
rev: "v2.15.5"
hooks:
- id: pylint
exclude: "test_*"
Expand All @@ -155,37 +170,50 @@ repos:
rev: "v0.982"
hooks:
- id: mypy
exclude: "test_starlette_tests"
args: [--show-traceback, --pdb]
additional_dependencies:
[
aiomcache,
beautifulsoup4,
brotli,
cryptography,
freezegun,
httpx,
hypothesis,
mako,
orjson,
piccolo,
picologging,
pydantic,
pydantic_factories,
pydantic_openapi_schema,
pytest,
pyyaml,
redis,
sqlalchemy,
sqlalchemy2-stubs,
starlette,
starlite_multipart,
structlog,
tortoise-orm,
types-PyYAML,
types-beautifulsoup4,
types-freezegun,
types-redis,
redis,
]
- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.275
rev: v1.1.276
hooks:
- id: pyright
exclude: "tests"
additional_dependencies:
[
aiomcache,
beautifulsoup4,
brotli,
cryptography,
freezegun,
httpx,
hypothesis,
jinja2,
mako,
orjson,
piccolo,
Expand All @@ -196,11 +224,14 @@ repos:
pytest,
pyyaml,
redis,
httpx,
sqlalchemy,
sqlalchemy2-stubs,
starlette,
starlite_multipart,
structlog,
aiomcache,
tortoise-orm,
types-PyYAML,
types-beautifulsoup4,
types-freezegun,
types-redis,
]
13 changes: 0 additions & 13 deletions docs/reference/4-response.md

This file was deleted.

30 changes: 27 additions & 3 deletions docs/reference/datastructures/5-response-containers.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,58 @@
options:
members:
- background
- headers
- cookies
- encoding
- headers
- media_type
- to_response

::: starlite.datastructures.File
options:
members:
- path
- background
- chunk_size
- content_disposition_type
- cookies
- encoding
- etag
- filename
- headers
- media_type
- path
- stat_result
- to_response
- to_response

::: starlite.datastructures.Redirect
options:
members:
- background
- cookies
- headers
- path
- to_response

::: starlite.datastructures.Stream
options:
members:
- background
- cookies
- encoding
- headers
- iterator
- media_type
- to_response

::: starlite.datastructures.Template
options:
members:
- name
- background
- context
- cookies
- encoding
- headers
- media_type
- name
- to_response
- update_context
18 changes: 18 additions & 0 deletions docs/reference/response/0-base.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Base HTTP Response

::: starlite.response.Response
options:
members:
- __init__
- __call__
- after_response
- content_length
- delete_cookie
- encoded_headers
- render
- send_body
- serializer
- set_cookie
- set_etag
- set_header
- start_response
16 changes: 16 additions & 0 deletions docs/reference/response/1-streaming.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Streaming Response

::: starlite.response.StreamingResponse
options:
members:
- __init__
- __call__
- after_response
- content_length
- delete_cookie
- encoded_headers
- send_body
- set_cookie
- set_etag
- set_header
- start_response
16 changes: 16 additions & 0 deletions docs/reference/response/2-file.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# File Response

::: starlite.response.FileResponse
options:
members:
- __init__
- __call__
- after_response
- content_length
- delete_cookie
- encoded_headers
- send_body
- set_cookie
- set_etag
- set_header
- start_response
16 changes: 16 additions & 0 deletions docs/reference/response/3-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Template Response

::: starlite.response.TemplateResponse
options:
members:
- __init__
- __call__
- after_response
- content_length
- delete_cookie
- encoded_headers
- send_body
- set_cookie
- set_etag
- set_header
- start_response
16 changes: 16 additions & 0 deletions docs/reference/response/4-redirect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Redirect Response

::: starlite.response.RedirectResponse
options:
members:
- __init__
- __call__
- after_response
- content_length
- delete_cookie
- encoded_headers
- send_body
- set_cookie
- set_etag
- set_header
- start_response
2 changes: 0 additions & 2 deletions docs/reference/utils/0-predicate-utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

::: starlite.utils.predicates.T

::: starlite.utils.predicates.is_async_callable

::: starlite.utils.predicates.is_class_and_subclass

::: starlite.utils.predicates.is_dataclass_class_or_instance_typeguard
Expand Down
7 changes: 7 additions & 0 deletions docs/reference/utils/1-sync-utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

::: starlite.utils.sync.T

::: starlite.utils.is_async_callable

::: starlite.utils.AsyncCallable
options:
members:
Expand All @@ -13,3 +15,8 @@
::: starlite.utils.as_async_callable_list

::: starlite.utils.async_partial

::: starlite.utils.AsyncIteratorWrapper
options:
members:
- __init__
Loading

0 comments on commit 0949b14

Please sign in to comment.