Skip to content

Improve serializer typing #71

@khvn26

Description

@khvn26

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions