Commit 601f985f authored by Laurent Peuch's avatar Laurent Peuch
Browse files

[types] add more types in schema.py

parent ba713e9ce2c8
......@@ -336,12 +336,12 @@ class EntitySchema(PermissionMixIn, ERSchema):
# navigation ######################
def specializes(self) -> Any:
def specializes(self) -> Optional["EntitySchema"]:
if self._specialized_type and self.schema is not None:
return self.schema.entity_schema_for(yams_types.DefinitionName(self._specialized_type))
return None
def ancestors(self) -> List:
def ancestors(self) -> List["EntitySchema"]:
specializes = self.specializes()
ancestors = []
......@@ -365,7 +365,7 @@ class EntitySchema(PermissionMixIn, ERSchema):
return subject_schemas
@deprecation.argument_renamed(old_name="rtype", new_name="relation_type")
def has_relation(self, relation_type, role: str) -> bool:
def has_relation(self, relation_type: yams_types.RelationType, role: str) -> bool:
if role == "subject":
return relation_type in self._subject_relations
......
......@@ -235,7 +235,9 @@ class OneHopESchemaVisitor(SchemaVisitor):
# Inheritance relations.
if eschema.specializes():
nodes.add((eschema.specializes().type, eschema.specializes()))
entity_schema_specialisation = eschema.specializes()
assert entity_schema_specialisation is not None
nodes.add((entity_schema_specialisation.type, entity_schema_specialisation))
# mypy: Argument 1 to "add" of "set" has incompatible type "Tuple[str, Any, None]";
# mypy: expected "Tuple[str, str, RelationSchema]"
# situation too complex for mypy to handle
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment