Description:
Some model attributes in pesuacademy-py, such as blood_group, have a fixed set of known deterministic values.
Currently, these are typed as str, which is too generic and does not provide compile-time validation or IDE auto-completion for allowed values. Additionally, during profile parsing (in _ProfilePageHandler._parse_profile_soup), we should validate that the extracted blood_group exactly matches one of the allowed values before storing it.
Proposed Change:
- Replace
str annotations with Literal where applicable.
Example:
from typing import Literal
blood_group: Literal["A+", "A-", "B+", "B-", "AB+", "AB-", "O+", "O-"]
- In
_ProfilePageHandler._parse_profile_soup, check that the parsed blood_group exactly matches one of the allowed values before assigning it to the model.
- Review all models for similar attributes and update accordingly.
Benefits:
- Improves type safety and reduces risk of invalid values.
- Enhances developer experience with better auto-completion and inline documentation in IDEs.
Description:
Some model attributes in
pesuacademy-py, such asblood_group, have a fixed set of known deterministic values.Currently, these are typed as
str, which is too generic and does not provide compile-time validation or IDE auto-completion for allowed values. Additionally, during profile parsing (in_ProfilePageHandler._parse_profile_soup), we should validate that the extractedblood_groupexactly matches one of the allowed values before storing it.Proposed Change:
strannotations withLiteralwhere applicable.Example:
_ProfilePageHandler._parse_profile_soup, check that the parsedblood_groupexactly matches one of the allowed values before assigning it to the model.Benefits: