Skip to content
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

refactor: improve ch3 with setdefault, mongo simplification and consistent typing #29

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

weiyu-huang
Copy link

This PR improves code quality in Chapter 3:

  1. Enhance metadata handling:

    • Use dict.setdefault() in add_to_metadata for cleaner default value handling
    • Simplify code by removing redundant dictionary checks
  2. Simplify MongoDB handling:

    • Remove redundant conversion logic in to_mongo method
  3. Modernize type hints:

    • Update to str | None syntax for consistency with surrounding code

Move UUID string conversion to model_dump to avoid duplicate logic. UUID conversion now happens once during initial dump instead of repeating in to_mongo.
Change Optional[str] to str | None for improved readability
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant