Skip to content

feat: support starlette v1#2170

Open
waketzheng wants to merge 14 commits intotortoise:developfrom
waketzheng:starlette-v1
Open

feat: support starlette v1#2170
waketzheng wants to merge 14 commits intotortoise:developfrom
waketzheng:starlette-v1

Conversation

@waketzheng
Copy link
Copy Markdown
Contributor

Description

Currently, when I run

cd examples/starlette
uv pip install uvicorn
python main.py

Output is:

Traceback (most recent call last):
  File "/Users/mac10.12/github/tortoise-orm/examples/starlette/main.py", line 20, in <module>
    @app.route("/", methods=["GET"])
     ^^^^^^^^^
AttributeError: 'Starlette' object has no attribute 'route'. Did you mean: 'router'?

After changed it to be using Route, it raises:

Traceback (most recent call last):
  File "/Users/mac10.12/github/tortoise-orm/examples/starlette/main.py", line 44, in <module>
    register_tortoise(
    ~~~~~~~~~~~~~~~~~^
        app, db_url="sqlite://:memory:", modules={"models": ["models"]}, generate_schemas=True
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/Users/mac10.12/github/tortoise-orm/tortoise/contrib/starlette/__init__.py", line 83, in register_tortoise
    @app.on_event("startup")
     ^^^^^^^^^^^^
AttributeError: 'Starlette' object has no attribute 'on_event'

Motivation and Context

To support starlette 1.0.0

How Has This Been Tested?

ci

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added the changelog accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 5, 2026

Merging this PR will not alter performance

✅ 24 untouched benchmarks


Comparing waketzheng:starlette-v1 (702f9d6) with develop (a394ab2)

Open in CodSpeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant