Skip to content

Yan Zhou | Oct2025-1 | Tools | Sprint 5 | Types and Typechecking - #8

Open
yanzhou-git wants to merge 1 commit into
mainfrom
types
Open

Yan Zhou | Oct2025-1 | Tools | Sprint 5 | Types and Typechecking#8
yanzhou-git wants to merge 1 commit into
mainfrom
types

Conversation

@yanzhou-git

Copy link
Copy Markdown
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant