Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobCoffee authored Mar 9, 2024
2 parents 2725ebd + 65efff1 commit 05ed293
Show file tree
Hide file tree
Showing 149 changed files with 4,961 additions and 1,730 deletions.
69 changes: 68 additions & 1 deletion .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,9 @@
"avatar_url": "https://avatars.githubusercontent.com/u/35638715?v=4",
"profile": "https://github.com/kedod",
"contributions": [
"doc"
"doc",
"code",
"test"
]
},
{
Expand Down Expand Up @@ -1602,6 +1604,71 @@
"contributions": [
"bug"
]
},
{
"login": "betaprior",
"name": "Leo Alekseyev",
"avatar_url": "https://avatars.githubusercontent.com/u/338250?v=4",
"profile": "http://dnquark.com",
"contributions": [
"code"
]
},
{
"login": "aranvir",
"name": "aranvir",
"avatar_url": "https://avatars.githubusercontent.com/u/75439739?v=4",
"profile": "https://github.com/aranvir",
"contributions": [
"doc"
]
},
{
"login": "bunny-therapist",
"name": "bunny-therapist",
"avatar_url": "https://avatars.githubusercontent.com/u/87039365?v=4",
"profile": "https://github.com/bunny-therapist",
"contributions": [
"code"
]
},
{
"login": "benluo",
"name": "Ben Luo",
"avatar_url": "https://avatars.githubusercontent.com/u/70398?v=4",
"profile": "http://www.benluo.cc",
"contributions": [
"doc"
]
},
{
"login": "hugovk",
"name": "Hugo van Kemenade",
"avatar_url": "https://avatars.githubusercontent.com/u/1324225?v=4",
"profile": "https://github.com/hugovk",
"contributions": [
"doc"
]
},
{
"login": "error418",
"name": "Michael Gerbig",
"avatar_url": "https://avatars.githubusercontent.com/u/7716544?v=4",
"profile": "https://error418.github.io",
"contributions": [
"doc"
]
},
{
"login": "crisog",
"name": "CrisOG",
"avatar_url": "https://avatars.githubusercontent.com/u/40803711?v=4",
"profile": "https://github.com/crisog",
"contributions": [
"bug",
"code",
"test"
]
}
],
"contributorsPerLine": 7,
Expand Down
7 changes: 7 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@ By submitting this pull request, you agree to:
- follow [Litestar's contribution guidelines](https://github.com/litestar-org/.github/blob/main/CONTRIBUTING.md)
- follow the [PSFs's Code of Conduct](https://www.python.org/psf/conduct/)
-->
## Description

-

<!--
Please add in issue numbers this pull request will close, if applicable
Examples: Fixes #4321 or Closes #1234
Ensure you are using a supported keyword to properly link an issue:
https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword
-->
## Closes
42 changes: 39 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,41 @@ jobs:
coverage: ${{ (matrix.python-version == '3.12' || matrix.python-version == '3.8') }}
python-version: ${{ matrix.python-version }}

test_integration:
name: Test server integration
runs-on: ubuntu-latest
strategy:
matrix:
uvicorn-version: ["uvicorn<0.27.0", "uvicorn>=0.27.0"]
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.11

- uses: pdm-project/setup-pdm@v4
name: Set up PDM
with:
python-version: 3.11
allow-python-prereleases: false
cache: true
cache-dependency-path: |
./pdm.lock
- name: Install dependencies
run: |
pdm install -G:all
pip install -U "${{ matrix.uvicorn-version }}"
- name: Set PYTHONPATH
run: echo "PYTHONPATH=$PWD" >> $GITHUB_ENV

- name: Test
run: pdm run pytest tests -m server_integration

upload-test-coverage:
runs-on: ubuntu-latest
needs: test
Expand All @@ -112,16 +147,17 @@ jobs:
python -Im coverage combine
python -Im coverage xml -i
- name: Fix coverage file for sonarcloud
- name: Fix coverage file name
run: sed -i "s/home\/runner\/work\/litestar\/litestar/github\/workspace/g" coverage.xml

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
files: coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}

test-platform-compat:
if: github.event_name == 'push'
if: github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'test platform compat')
strategy:
fail-fast: false
matrix:
Expand Down
13 changes: 2 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ repos:
- id: unasyncd
additional_dependencies: ["ruff"]
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.1.14"
rev: "v0.2.1"
hooks:
- id: ruff
args: ["--fix"]
Expand All @@ -35,23 +35,14 @@ repos:
exclude: "tests/openapi/typescript_converter/test_converter|README.md"
additional_dependencies:
- tomli
- repo: https://github.com/asottile/blacken-docs
rev: 1.16.0
hooks:
- id: blacken-docs
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v4.0.0-alpha.8"
hooks:
- id: prettier
exclude: "_templates|.git|.all-contributorsrc"
- repo: https://github.com/python-formate/flake8-dunder-all
rev: v0.3.1
hooks:
- id: ensure-dunder-all
exclude: "test*|examples*|tools"
args: ["--use-tuple"]
- repo: https://github.com/ariebovenberg/slotscheck
rev: v0.17.1
rev: v0.17.3
hooks:
- id: slotscheck
exclude: "test_*|docs|.github"
Expand Down
20 changes: 10 additions & 10 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Workflow
5. (Optional) Run ``pre-commit run --all-files`` to run linters and formatters. This step is optional and will be executed
automatically by git before you make a commit, but you may want to run it manually in order to apply fixes
6. Commit your changes to git. Note - we follow [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/),
which are enforced using a `pre-commit` hook.
which are enforced using a ``pre-commit`` hook.
7. Push the changes to your fork
8. Open a `pull request <https://docs.github.com/en/pull-requests>`_. Give the pull request a descriptive title
indicating what it changes. The style of the PR title should also follow
Expand All @@ -56,7 +56,7 @@ Guidelines for writing code

- Code should be `Pythonic and zen <https://peps.python.org/pep-0020/>`_
- All code should be fully `typed <https://peps.python.org/pep-0484/>`_. This is enforced via
`mypy <https://mypy.readthedocs.io/en/stable/>`_ and `pyright <https://github.com/microsoft/pyright/>`_
`mypy <https://mypy.readthedocs.io/en/stable/>`_ and `Pyright <https://github.com/microsoft/pyright/>`_

* When requiring complex types, use a `type alias <https://docs.python.org/3/library/typing.html#type-aliases>`_.
Check ``litestar/types`` if a type alias for your use case already exists
Expand All @@ -76,7 +76,7 @@ Guidelines for writing code
across a function or method that doesn't conform to this standard, please update it as you go
- When adding a new public interface, it has to be included in the reference documentation located in
``docs/reference``. If applicable, add or modify examples in the docs related to the new functionality implemented,
following the guidelines established in `Adding examples`_
following the guidelines established in `Adding examples`_.


Writing and running tests
Expand Down Expand Up @@ -115,16 +115,16 @@ Our type checkers are run on Python 3.8 in CI, so you should make sure to run th
Project documentation
---------------------

The documentation is located in the ``/docs`` directory and is `ReST <https://docutils.sourceforge.io/rst.html>`_ and
The documentation is located in the ``/docs`` directory and is `reST <https://docutils.sourceforge.io/rst.html>`_ and
`Sphinx <https://www.sphinx-doc.org/en/master/>`_. If you're unfamiliar with any of those,
`ReStructuredText primer <https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html>`_ and
`reStructuredText primer <https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html>`_ and
`Sphinx quickstart <https://www.sphinx-doc.org/en/master/usage/quickstart.html>`_ are recommended reads.

Docs theme and appearance
+++++++++++++++++++++++++

We welcome contributions that enhance / improve the appearance and usability of the docs. We use the excellent
`Furo <https://pradyunsg.me/furo/quickstart/>`_ theme, which comes with a lot of options out of the box. If you wish to
`PyData Sphinx Theme <https://pydata-sphinx-theme.readthedocs.io/>`_ theme, which comes with a lot of options out of the box. If you wish to
contribute to the docs style / setup, or static site generation, you should consult the theme docs as a first step.

Running the docs locally
Expand All @@ -142,13 +142,13 @@ Writing and editing docs
We welcome contributions that enhance / improve the content of the docs. Feel free to add examples, clarify text,
restructure the docs, etc., but make sure to follow these guidelines:

- Write text in idiomatic english, using simple language
- Write text in idiomatic English, using simple language
- Opt for `Oxford commas <https://en.wikipedia.org/wiki/Serial_comma>`_ when listing a series of terms
- Keep examples simple and self contained
- Provide links where applicable
- Use `intersphinx <https://www.sphinx-doc.org/en/master/usage/extensions/intersphinx.html>`_ wherever possible when
referencing external libraries
- Provide diagrams using `mermaidjs <https://mermaid.js.org/>`_ where applicable and possible
- Provide diagrams using `Mermaid <https://mermaid.js.org/>`_ where applicable and possible

Adding examples
~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -182,7 +182,7 @@ will be launched, and the requests specified in the comments will be run against
comments will be stripped from the result, and the output of the ``curl`` invocation inserted
after the example code-block.

The ``# run:`` syntax is nothing special; Everything after the colon will be passed to
The ``# run:`` syntax is nothing special; everything after the colon will be passed to
the ``curl`` command that's being invoked. The URL is built automatically, so the
specified path can just be a path relative to the app.

Expand Down Expand Up @@ -237,7 +237,7 @@ Creating a new release

1. Increment the version in ``pyproject.toml`` according to the `versioning scheme <https://litestar.dev/about/litestar-releases#version-numbering>`_
.. note::
The version should follow `semantic versioning <https://semver.org/>`_ and `PEP 440 <https://www.python.org/dev/peps/pep-0440/>`_.
The version should follow `semantic versioning <https://semver.org/>`_ and `PEP 440 <https://peps.python.org/pep-0440/>`_.

2. Commit and push.
2. `Draft a new release <https://github.com/litestar-org/litestar/releases/new>`_ on GitHub
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ see [the contribution guide](CONTRIBUTING.rst).
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/tompin82"><img src="https://avatars.githubusercontent.com/u/47041409?v=4?s=100" width="100px;" alt="Tomas Jonsson"/><br /><sub><b>Tomas Jonsson</b></sub></a><br /><a href="https://github.com/litestar-org/litestar/commits?author=tompin82" title="Tests">⚠️</a> <a href="https://github.com/litestar-org/litestar/commits?author=tompin82" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://www.linkedin.com/in/khiem-doan/"><img src="https://avatars.githubusercontent.com/u/15646249?v=4?s=100" width="100px;" alt="Khiem Doan"/><br /><sub><b>Khiem Doan</b></sub></a><br /><a href="https://github.com/litestar-org/litestar/commits?author=khiemdoan" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/kedod"><img src="https://avatars.githubusercontent.com/u/35638715?v=4?s=100" width="100px;" alt="kedod"/><br /><sub><b>kedod</b></sub></a><br /><a href="https://github.com/litestar-org/litestar/commits?author=kedod" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/kedod"><img src="https://avatars.githubusercontent.com/u/35638715?v=4?s=100" width="100px;" alt="kedod"/><br /><sub><b>kedod</b></sub></a><br /><a href="https://github.com/litestar-org/litestar/commits?author=kedod" title="Documentation">📖</a> <a href="https://github.com/litestar-org/litestar/commits?author=kedod" title="Code">💻</a> <a href="https://github.com/litestar-org/litestar/commits?author=kedod" title="Tests">⚠️</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/sonpro1296"><img src="https://avatars.githubusercontent.com/u/17319142?v=4?s=100" width="100px;" alt="sonpro1296"/><br /><sub><b>sonpro1296</b></sub></a><br /><a href="https://github.com/litestar-org/litestar/commits?author=sonpro1296" title="Code">💻</a> <a href="https://github.com/litestar-org/litestar/commits?author=sonpro1296" title="Tests">⚠️</a> <a href="#infra-sonpro1296" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="https://github.com/litestar-org/litestar/commits?author=sonpro1296" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://patrickarmengol.com"><img src="https://avatars.githubusercontent.com/u/42473149?v=4?s=100" width="100px;" alt="Patrick Armengol"/><br /><sub><b>Patrick Armengol</b></sub></a><br /><a href="https://github.com/litestar-org/litestar/commits?author=patrickarmengol" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://sanderwegter.nl"><img src="https://avatars.githubusercontent.com/u/7465799?v=4?s=100" width="100px;" alt="Sander"/><br /><sub><b>Sander</b></sub></a><br /><a href="https://github.com/litestar-org/litestar/commits?author=SanderWegter" title="Documentation">📖</a></td>
Expand Down Expand Up @@ -540,6 +540,15 @@ see [the contribution guide](CONTRIBUTING.rst).
<td align="center" valign="top" width="14.28%"><a href="https://github.com/korneevm"><img src="https://avatars.githubusercontent.com/u/743250?v=4?s=100" width="100px;" alt="Mike Korneev"/><br /><sub><b>Mike Korneev</b></sub></a><br /><a href="https://github.com/litestar-org/litestar/commits?author=korneevm" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/patrickneise"><img src="https://avatars.githubusercontent.com/u/6312074?v=4?s=100" width="100px;" alt="Patrick Neise"/><br /><sub><b>Patrick Neise</b></sub></a><br /><a href="https://github.com/litestar-org/litestar/commits?author=patrickneise" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/JeanArhancet"><img src="https://avatars.githubusercontent.com/u/10811879?v=4?s=100" width="100px;" alt="Jean Arhancet"/><br /><sub><b>Jean Arhancet</b></sub></a><br /><a href="https://github.com/litestar-org/litestar/issues?q=author%3AJeanArhancet" title="Bug reports">🐛</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://dnquark.com"><img src="https://avatars.githubusercontent.com/u/338250?v=4?s=100" width="100px;" alt="Leo Alekseyev"/><br /><sub><b>Leo Alekseyev</b></sub></a><br /><a href="https://github.com/litestar-org/litestar/commits?author=betaprior" title="Code">💻</a></td>
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/aranvir"><img src="https://avatars.githubusercontent.com/u/75439739?v=4?s=100" width="100px;" alt="aranvir"/><br /><sub><b>aranvir</b></sub></a><br /><a href="https://github.com/litestar-org/litestar/commits?author=aranvir" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/bunny-therapist"><img src="https://avatars.githubusercontent.com/u/87039365?v=4?s=100" width="100px;" alt="bunny-therapist"/><br /><sub><b>bunny-therapist</b></sub></a><br /><a href="https://github.com/litestar-org/litestar/commits?author=bunny-therapist" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://www.benluo.cc"><img src="https://avatars.githubusercontent.com/u/70398?v=4?s=100" width="100px;" alt="Ben Luo"/><br /><sub><b>Ben Luo</b></sub></a><br /><a href="https://github.com/litestar-org/litestar/commits?author=benluo" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/hugovk"><img src="https://avatars.githubusercontent.com/u/1324225?v=4?s=100" width="100px;" alt="Hugo van Kemenade"/><br /><sub><b>Hugo van Kemenade</b></sub></a><br /><a href="https://github.com/litestar-org/litestar/commits?author=hugovk" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://error418.github.io"><img src="https://avatars.githubusercontent.com/u/7716544?v=4?s=100" width="100px;" alt="Michael Gerbig"/><br /><sub><b>Michael Gerbig</b></sub></a><br /><a href="https://github.com/litestar-org/litestar/commits?author=error418" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/crisog"><img src="https://avatars.githubusercontent.com/u/40803711?v=4?s=100" width="100px;" alt="CrisOG"/><br /><sub><b>CrisOG</b></sub></a><br /><a href="https://github.com/litestar-org/litestar/issues?q=author%3Acrisog" title="Bug reports">🐛</a> <a href="https://github.com/litestar-org/litestar/commits?author=crisog" title="Code">💻</a> <a href="https://github.com/litestar-org/litestar/commits?author=crisog" title="Tests">⚠️</a></td>
</tr>
</tbody>
</table>
Expand Down
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@
("py:exc", "InternalServerError"),
("py:exc", "HTTPExceptions"),
(PY_CLASS, "litestar.template.Template"),
(PY_CLASS, "litestar.middleware.compression.gzip_facade.GzipCompression"),
]

nitpick_ignore_regex = [
Expand Down
5 changes: 1 addition & 4 deletions docs/examples/contrib/piccolo/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,4 @@ async def on_startup():
await create_db_tables(Task, if_not_exists=True)


app = Litestar(
route_handlers=[tasks, create_task, delete_task, update_task],
on_startup=[on_startup],
)
app = Litestar(route_handlers=[tasks, create_task, delete_task, update_task], on_startup=[on_startup], debug=True)
31 changes: 31 additions & 0 deletions docs/examples/plugins/di_plugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from inspect import Parameter, Signature
from typing import Any, Dict, Tuple

from litestar import Litestar, get
from litestar.di import Provide
from litestar.plugins import DIPlugin


class MyBaseType:
def __init__(self, param):
self.param = param


class MyDIPlugin(DIPlugin):
def has_typed_init(self, type_: Any) -> bool:
return issubclass(type_, MyBaseType)

def get_typed_init(self, type_: Any) -> Tuple[Signature, Dict[str, Any]]:
signature = Signature([Parameter(name="param", kind=Parameter.POSITIONAL_OR_KEYWORD)])
annotations = {"param": str}
return signature, annotations


@get("/", dependencies={"injected": Provide(MyBaseType, sync_to_thread=False)})
async def handler(injected: MyBaseType) -> str:
return injected.param


app = Litestar(route_handlers=[handler], plugins=[MyDIPlugin()])

# run: /?param=hello
2 changes: 1 addition & 1 deletion docs/examples/security/jwt/using_jwt_cookie_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async def retrieve_user_handler(token: "Token", connection: "ASGIConnection[Any,
# and our openAPI docs.
exclude=["/login", "/schema"],
# Tip: We can optionally supply cookie options to the configuration. Here is an example of enabling the secure cookie option
# auth_cookie_options=CookieOptions(secure=True),
# secure=True,
)


Expand Down
Empty file.
18 changes: 18 additions & 0 deletions docs/examples/static_files/custom_router.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from litestar import Litestar
from litestar.router import Router
from litestar.static_files import create_static_files_router


class MyRouter(Router):
pass


app = Litestar(
route_handlers=[
create_static_files_router(
path="/static",
directories=["assets"],
router_class=MyRouter,
)
]
)
Loading

0 comments on commit 05ed293

Please sign in to comment.