Skip to content

Commit

Permalink
Rename FIELD_MSG_TYPE -> _FIELD_TYPE
Browse files Browse the repository at this point in the history
  • Loading branch information
vinhowe committed Jul 26, 2021
1 parent 408e287 commit ec4cd11
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions footron_controller/experiences.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
)
from .constants import EXPERIENCES_PATH, JsonDict

FIELD_MSG_TYPE = "type"
_FIELD_TYPE = "type"


class ExperienceType(str, Enum):
Expand Down Expand Up @@ -82,13 +82,13 @@ def create_environment(self) -> VideoEnvironment:


def _serialize_experience(data: JsonDict, path: Path) -> BaseExperience:
if FIELD_MSG_TYPE not in data:
raise TypeError(f"Experience doesn't contain required field '{FIELD_MSG_TYPE}'")
if _FIELD_TYPE not in data:
raise TypeError(f"Experience doesn't contain required field '{_FIELD_TYPE}'")

if not isinstance(data[FIELD_MSG_TYPE], ExperienceType):
data[FIELD_MSG_TYPE] = ExperienceType(data[FIELD_MSG_TYPE])
if not isinstance(data[_FIELD_TYPE], ExperienceType):
data[_FIELD_TYPE] = ExperienceType(data[_FIELD_TYPE])

msg_type: ExperienceType = data[FIELD_MSG_TYPE]
msg_type: ExperienceType = data[_FIELD_TYPE]

return experience_type_map[msg_type](**data, path=path)

Expand Down

0 comments on commit ec4cd11

Please sign in to comment.