Yan Zhou | Oct2025-1 | Tools | Sprint 5 | Types and Typechecking - #8
Open
yanzhou-git wants to merge 1 commit into
Open
Yan Zhou | Oct2025-1 | Tools | Sprint 5 | Types and Typechecking#8yanzhou-git wants to merge 1 commit into
yanzhou-git wants to merge 1 commit into
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Core theme: Catch bugs before running code — using types, mypy, classes, and enums.
✅ Self-Checklist
Added type annotations to functions and caught bugs with mypy.
Built a Person class with init, methods, and datetime.date for age.
Used @DataClass(frozen=True) to auto-generate constructors, equality, and print.
Used List[Person] generics so mypy knows what's inside a list.
Refactored preferred_operating_system from str to List[str], guided by mypy errors.
Used Enum to replace unsafe strings like "ubuntu" with OperatingSystem.UBUNTU.
Validated user input early, output errors to stderr, and exit with non-zero code.
Explored inheritance where a subclass overrides largest() with a faster implementation.
🔄 Changelist
mypy + annotations for bug detection without running code, class and @DataClass for grouping related data and methods, List[str] and List[Person] for typed containers, Enum for a fixed set of valid values, and inheritance with super().init() for reusing and extending a class.