-
-
Notifications
You must be signed in to change notification settings - Fork 782
♻️ Ignore on_event is deprecated deprecation warnings, fix ValidationError import warning
#1600
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
♻️ Ignore on_event is deprecated deprecation warnings, fix ValidationError import warning
#1600
Conversation
📝 Docs preview
Last commit 7c8a330 at: https://4709c771.sqlmodel.pages.dev
@svlandeg
svlandeg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I've forgotten/missed some previous discussion about this, but why don't we update the usage of on_event, e.g. like #958 attempts to do?
YuriiMotov
commented
Oct 21, 2025
Maybe I've forgotten/missed some previous discussion about this, but why don't we update the usage of
on_event, e.g. like #958 attempts to do?
#958 uses blocking function inside async lifespan function. That's not a good practice..
@asynccontextmanager async def lifespan(app: FastAPI): create_db_and_tables() yield
We can update it to run it in the threadpool, but it will make the code example more complicated..
Uh oh!
There was an error while loading. Please reload this page.
Currently we have a lot of deprecation warnings because we use
fastapi.on_eventin docs examples.These warnings are useless and make it hard to read log of tests.
I suggest we just ignore "on_event is deprecated" warnings globally.
I also fixed import of
ValidationErrorwhich also produced a deprecation warning.With Pydantic V2 we still have 1 type of warnings:
Not sure how to fix this one..
See log
With Pydantic V1 we still have a lot of warnings, but they are not easily fixable.
Anyway, with this PR we will have less warnings and it will be easier to review test logs