Loading src/coliverter/certifications/from_dict.py 0 → 100644 +18 −0 Original line number Diff line number Diff line from collections.abc import Mapping from typing import Any, get_args from coliverter.certifications.FachschaftCertification import FachschaftCertification # The types of certification the coliverter can produce type ColiCertification = FachschaftCertification certification_classes: Mapping[str, type[ColiCertification]] = { cls.required_office_kind_name: cls for cls in get_args(ColiCertification.__value__) } def from_dict(certification_request: dict[str, Any]) -> ColiCertification: # Variable name has a capital C, because it is a class, so this makes the next line look nicer Certification = certification_classes[certification_request["office"]["kind"]["name"]] # noqa: N806 return Certification.from_dict(certification_request) Loading
src/coliverter/certifications/from_dict.py 0 → 100644 +18 −0 Original line number Diff line number Diff line from collections.abc import Mapping from typing import Any, get_args from coliverter.certifications.FachschaftCertification import FachschaftCertification # The types of certification the coliverter can produce type ColiCertification = FachschaftCertification certification_classes: Mapping[str, type[ColiCertification]] = { cls.required_office_kind_name: cls for cls in get_args(ColiCertification.__value__) } def from_dict(certification_request: dict[str, Any]) -> ColiCertification: # Variable name has a capital C, because it is a class, so this makes the next line look nicer Certification = certification_classes[certification_request["office"]["kind"]["name"]] # noqa: N806 return Certification.from_dict(certification_request)