MCPcopy Index your code
hub / github.com/MongoEngine/mongoengine / to_python

Method to_python

mongoengine/fields.py:1646–1653  ·  view source on GitHub ↗
(self, value)

Source from the content-addressed store, hash-verified

1644 self.error(f"{value} is not a valid {self._enum_cls}")
1645
1646 def to_python(self, value):
1647 value = super().to_python(value)
1648 if not isinstance(value, self._enum_cls):
1649 try:
1650 return self._enum_cls(value)
1651 except ValueError:
1652 return value
1653 return value
1654
1655 def __set__(self, instance, value):
1656 return super().__set__(instance, self.to_python(value))

Callers 1

__set__Method · 0.95

Calls 1

to_pythonMethod · 0.45

Tested by

no test coverage detected