Skip to content

FlagType enum definition causes problems with mypy #135

Description

@federicobond

Running mypy on the sdk codebase I found several errors. One of them stood out:

open_feature/open_feature_client.py:202: error: Argument 1 to "evaluate_flag_details" of "OpenFeatureClient" has incompatible type "<typing special form>"; expected "FlagType"  [arg-type]

This corresponds to the following call:

return self.evaluate_flag_details(
FlagType.OBJECT,
flag_key,
default_value,
evaluation_context,
flag_evaluation_options,
)

It appears that mypy has problems recognizing the value of FlagType.OBJECT as a member of FlagType.

class FlagType(Enum):
    BOOLEAN = bool
    STRING = str
    OBJECT = typing.Union[dict, list]
    FLOAT = float
    INTEGER = int

As we can see, OBJECT is the only value that is not a standard type class.

Using types as enum values like this is not very common and has the potential to cause issues with other tools too. Moving to standard str or int enum values may avoid such problems. If there is consensus in this I can open a pull request with the necessary changes.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions