diff --git a/followthemoney/proxy.py b/followthemoney/proxy.py index 19eb8b2b7..11caadbfb 100644 --- a/followthemoney/proxy.py +++ b/followthemoney/proxy.py @@ -87,7 +87,8 @@ def __init__( continue if cleaned: # This does not call `self.add` as it might be called millions of times - # in some context and we want to avoid the performance overhead of doing so. + # in some context and we want to avoid the performance overhead of + # doing so. seen: Set[str] = set() seen_add = seen.add unique_values = [v for v in values if not (v in seen or seen_add(v))] @@ -335,8 +336,9 @@ def countries(self) -> List[str]: @property def temporal_start(self) -> Optional[Tuple[Property, str]]: - """Get a date that can be used to represent the start of the entity in a timeline. - If there are multiple possible dates, the earliest date is returned.""" + """Get a date that can be used to represent the start of the entity in a + timeline. If there are multiple possible dates, the earliest date is + returned.""" values = [] for prop in self.schema.temporal_start_props: @@ -467,7 +469,7 @@ def __len__(self) -> int: def __hash__(self) -> int: if not self.id: warnings.warn( - "Taking the hash of an EntityProxy without an ID set results in undefined behaviour", + "Hashing an EntityProxy without an ID results in undefined behaviour", RuntimeWarning, ) return hash(self.id) @@ -476,7 +478,7 @@ def __eq__(self, other: Any) -> bool: try: if self.id is None or other.id is None: warnings.warn( - "Comparing EntityProxys without an ID set results in undefined behaviour", + "Comparing EntityProxys without IDs results in undefined behaviour", RuntimeWarning, ) return bool(self.id == other.id) diff --git a/followthemoney/schema.py b/followthemoney/schema.py index 60c2c5568..67bbf109f 100644 --- a/followthemoney/schema.py +++ b/followthemoney/schema.py @@ -176,11 +176,12 @@ def __init__(self, model: "Model", name: str, data: SchemaSpec) -> None: self.edge_caption = ensure_list(edge.get("caption", [])) self._edge_label = edge.get("label", self._label) - #: Flag to indicate if the edge should be presented as directed to the user, e.g. - #: by showing an error at the target end of the edge. + #: Flag to indicate if the edge should be presented as directed to the user, + #: e.g. by showing an error at the target end of the edge. self.edge_directed = as_bool(edge.get("directed", True)) - #: Specify which properties should be used to represent this schema in a timeline. + #: Specify which properties should be used to represent this schema in a + #: timeline. temporal_extent = data.get("temporalExtent", {}) self.temporal_start = set(temporal_extent.get("start", [])) self.temporal_end = set(temporal_extent.get("end", [])) @@ -189,7 +190,8 @@ def __init__(self, model: "Model", name: str, data: SchemaSpec) -> None: self._extends = ensure_list(data.get("extends", [])) self.extends: Set["Schema"] = set() - #: All parents of this schema (including indirect parents and the schema itself). + #: All parents of this schema (including indirect parents and the schema + #: itself). self.schemata = set([self]) #: All names of :attr:`~schemata`. @@ -309,13 +311,15 @@ def target_prop(self) -> Optional[Property]: @property def temporal_start_props(self) -> Set[Property]: - """The entity properties to be used as the start when representing the entity in a timeline.""" + """The entity properties to be used as the start when representing the entity + in a timeline.""" props = [self.get(prop_name) for prop_name in self.temporal_start] return set([prop for prop in props if prop is not None]) @property def temporal_end_props(self) -> Set[Property]: - """The entity properties to be used as the end when representing the entity in a timeline.""" + """The entity properties to be used as the end when representing the entity + in a timeline.""" props = [self.get(prop_name) for prop_name in self.temporal_end] return set([prop for prop in props if prop is not None]) @@ -334,8 +338,8 @@ def sorted_properties(self) -> List[Property]: @property def matchable_schemata(self) -> Set["Schema"]: - """Return the set of schemata to which it makes sense to compare with this schema. - For example, it makes sense to compare a legal entity with a company, + """Return the set of schemata to which it makes sense to compare with this + schema. For example, it makes sense to compare a legal entity with a company, but it does not make sense to compare a car and a person.""" if self._matchable_schemata is None: self._matchable_schemata = set()