Commit 25d31f47 authored by Laurent Peuch's avatar Laurent Peuch
Browse files

[rename] all those entity_type are actually entity_schema

parent 649e6df93853
Pipeline #9454 passed with stages
in 6 minutes and 12 seconds
......@@ -1286,49 +1286,51 @@ class RelationSchema(ERSchema):
# XXX deprecates in favor of iter_relation_definitions() ?
return list(self._subject_schemas.items())
@deprecation.argument_renamed(old_name="etype", new_name="entity_type")
def subjects(self, entity_type: Optional["EntitySchema"] = None) -> Tuple["EntitySchema", ...]:
@deprecation.argument_renamed(old_name="etype", new_name="entity_schema")
def subjects(
self, entity_schema: Optional["EntitySchema"] = None
) -> Tuple["EntitySchema", ...]:
"""Return a list of entity schemas which can be subject of this relation.
If entity_type is not None, return a list of schemas which can be subject of
this relation with entity_type as object.
If entity_schema is not None, return a list of schemas which can be subject of
this relation with entity_schema as object.
:raise `KeyError`: if entity_type is not a subject entity type.
:raise `KeyError`: if entity_schema is not a subject entity type.
"""
if entity_type is None:
if entity_schema is None:
return tuple(self._subject_schemas)
if entity_type in self._object_schemas:
return tuple(self._object_schemas[entity_type])
if entity_schema in self._object_schemas:
return tuple(self._object_schemas[entity_schema])
else:
raise KeyError(f"{self} does not have {entity_type} as object")
raise KeyError(f"{self} does not have {entity_schema} as object")
@deprecation.argument_renamed(old_name="etype", new_name="entity_type")
def objects(self, entity_type: Optional["EntitySchema"] = None) -> Tuple["EntitySchema", ...]:
@deprecation.argument_renamed(old_name="etype", new_name="entity_schema")
def objects(self, entity_schema: Optional["EntitySchema"] = None) -> Tuple["EntitySchema", ...]:
"""Return a list of entity schema which can be object of this relation.
If entity_type is not None, return a list of schemas which can be object of
this relation with entity_type as subject.
If entity_schema is not None, return a list of schemas which can be object of
this relation with entity_schema as subject.
:raise `KeyError`: if entity_type is not an object entity type.
:raise `KeyError`: if entity_schema is not an object entity type.
"""
if entity_type is None:
if entity_schema is None:
return tuple(self._object_schemas)
try:
return tuple(self._subject_schemas[entity_type])
return tuple(self._subject_schemas[entity_schema])
except KeyError:
raise KeyError(f"{self} does not have {entity_type} as subject")
raise KeyError(f"{self} does not have {entity_schema} as subject")
@deprecation.argument_renamed(old_name="etype", new_name="entity_type")
@deprecation.argument_renamed(old_name="etype", new_name="entity_schema")
def targets(
self, entity_type: Optional["EntitySchema"] = None, role: str = "subject"
self, entity_schema: Optional["EntitySchema"] = None, role: str = "subject"
) -> Tuple["EntitySchema", ...]:
"""return possible target types with <entity_type> as <x>"""
"""return possible target types with <entity_schema> as <x>"""
if role == "subject":
return self.objects(entity_type)
return self.objects(entity_schema)
return self.subjects(entity_type)
return self.subjects(entity_schema)
def relation_definition(
self, subject: yams_types.DefinitionName, object: yams_types.DefinitionName
......
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