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): ...@@ -336,12 +336,12 @@ class EntitySchema(PermissionMixIn, ERSchema):
# navigation ###################### # navigation ######################
def specializes(self) -> Any: def specializes(self) -> Optional["EntitySchema"]:
if self._specialized_type and self.schema is not None: if self._specialized_type and self.schema is not None:
return self.schema.entity_schema_for(yams_types.DefinitionName(self._specialized_type)) return self.schema.entity_schema_for(yams_types.DefinitionName(self._specialized_type))
return None return None
def ancestors(self) -> List: def ancestors(self) -> List["EntitySchema"]:
specializes = self.specializes() specializes = self.specializes()
ancestors = [] ancestors = []
...@@ -365,7 +365,7 @@ class EntitySchema(PermissionMixIn, ERSchema): ...@@ -365,7 +365,7 @@ class EntitySchema(PermissionMixIn, ERSchema):
return subject_schemas return subject_schemas
@deprecation.argument_renamed(old_name="rtype", new_name="relation_type") @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": if role == "subject":
return relation_type in self._subject_relations return relation_type in self._subject_relations
......
...@@ -235,7 +235,9 @@ class OneHopESchemaVisitor(SchemaVisitor): ...@@ -235,7 +235,9 @@ class OneHopESchemaVisitor(SchemaVisitor):
# Inheritance relations. # Inheritance relations.
if eschema.specializes(): 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: Argument 1 to "add" of "set" has incompatible type "Tuple[str, Any, None]";
# mypy: expected "Tuple[str, str, RelationSchema]" # mypy: expected "Tuple[str, str, RelationSchema]"
# situation too complex for mypy to handle # 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