Skip to content

fix: use X | None syntax instead of Optional in py310 code structure …#1785

Closed
martinhewing wants to merge 2 commits intofastapi:mainfrom
martinhewing:fix-optional-syntax-code-structure
Closed

fix: use X | None syntax instead of Optional in py310 code structure …#1785
martinhewing wants to merge 2 commits intofastapi:mainfrom
martinhewing:fix-optional-syntax-code-structure

Conversation

@martinhewing
Copy link

In docs_src/tutorial/code_structure/tutorial002_py310/hero_model.py,
the team field was still using Optional["Team"] while all other
fields had already been updated to use X | None syntax. This removes
the now-unused Optional import and updates the team field to use
"Team | None" — wrapped in quotes as required since Team is a
forward reference imported only under TYPE_CHECKING.

@github-actions github-actions bot added the docs Improvements or additions to documentation label Feb 25, 2026
@github-actions
Copy link
Contributor

📝 Docs preview

Last commit bf072b1 at: https://586c5d29.sqlmodel.pages.dev

Copy link
Member

@svlandeg svlandeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you can see from the failing tests, this doesn't actually work.

@martinhewing
Copy link
Author

Thanks for the review @svlandeg! Closing this one.

@martinhewing martinhewing deleted the fix-optional-syntax-code-structure branch February 25, 2026 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation waiting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants