Pybites Logo

Add type hints to a class

Level: Intermediate (score: 3)

In this Bite you'll add type hints to the provided Employee class, making the code more explicit and improving type checking, readability, and static analysis support.

Type hints provide clarity on the expected types of class attributes and method arguments.

Using a dataclass here ensures type annotations are available at the class level, which the tests rely on. It also reduces boilerplate by generating the constructor and other dunder methods automatically (see also this Bite).