Flagsmith / Flagsmith/flagsmith-common
Improve serializer typing
- Dominant language
- Python
- Stars
- 2
- Forks
- 4
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 10
Description
Currently, in order to use serializer classes imported from `flagsmith-common` in strictly typed codebases, we have to use `type: ignore` or `cast` created/updated instances to target model types.
We should look into the following:
1. Add a `TypeVar` to `SerializerWithMetadata` so subclasses can be annotated as e.g. `class FeatureSerializerWithMetadata(SerializerWithMetadata[Feature], CreateFeatureSerializer` in the consuming code.
2. In `common.types` module, try to import the Core API models under `if TYPE_CHECKING`, and only use type aliases to `model.Model` if they are not available.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.