-
Notifications
You must be signed in to change notification settings - Fork 147
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
Minor update to Navigation
docs
#190
Merged
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
1af0dc7
Fix docstrings and formatting
huong-li-nguyen 65d5581
Consolidate default formatting in docstrings
huong-li-nguyen 4ad350a
Remove className=hidden
huong-li-nguyen d2f97e6
Add changelog
huong-li-nguyen fb78e85
Add Optional to NavSelectorType
huong-li-nguyen afe2968
Add validator for icon name
huong-li-nguyen 86227d0
PR comments
huong-li-nguyen f62f041
CSS fix in case there are several icons
huong-li-nguyen 6b1683f
PR comments
huong-li-nguyen 85619df
Rename file
huong-li-nguyen 52d0d47
Update test_navigation.py
huong-li-nguyen 66b113c
Lint
huong-li-nguyen 32a1624
Merge branch 'main' into tidy/update_nav_docs
huong-li-nguyen 36138b8
Merge branch 'main' into tidy/update_nav_docs
huong-li-nguyen 9622e86
Merge branch 'main' into tidy/update_nav_docs
huong-li-nguyen 712067b
Update 0.1.7.dev1.json
huong-li-nguyen 8179bba
Merge branch 'main' into tidy/update_nav_docs
huong-li-nguyen b716d6f
Revert changes to Optional type hints
huong-li-nguyen 8c7e92b
Update docstrings
huong-li-nguyen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add Optional to NavSelectorType
- Loading branch information
commit fb78e851edfaf14eb228e2ab8efd18febfe4852a
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@antonymilne - here I wasn't sure whether the
Optional
was removed intentionally?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.
To be confirmed...
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.
After reading through this section of the migration guide for pydantic V2 and this forum post I don't have a strong preference, both should work fine.
To sum up the relevant parts:
Runtime implications
In practice this means that for the following model all fields behave identically in the sense that neither is required during initialization because all of them will receive None as their value, when no other value is provided, and the type of each of them is set to be Optional[str].
It seems that the g case, the one we are talking about here is under the hood converted to Optional[str] = None:
Migration to V2
What will change in pydantic V2 is the way how Optional[X] are handled if no defaults are provided as far as I understand e.g.
Optional[str]
andOptional[str] = None
were both considered as non-required and a default of None was automatically set in V1.This is not the case anymore with V2.
Optional[str]
without a default will be considered as a required field, whileOptional[str] = None
is not required, can be None, and is None by default. That being said you are right thatstr = None
will result in the same, so that field being considered as non-required, can be None and is None by default. So functionally both are the same.I have a slight preference for
Optional[XXX] = None
if we want to be more explicit, but as you already mentioned this sometimes leads to these mypy issues where we have to solve it via cast, making it a bit difficult to understand for new developers. So it’s questionable whether this improves it. So either solutions are actually fine for me :)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.
Interesting conversation.
Optional[XXX] = None
seems to be a little more what python developer are used to I guess, but if it causes other problems, happy to changeThere 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.
As discussed w/ @antonymilne : Changes will be reverted here and handled properly in separate PR
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.
See #210