diff --git a/dcicutils/structured_data.py b/dcicutils/structured_data.py index 5eeaa7bba..9cfd030b3 100644 --- a/dcicutils/structured_data.py +++ b/dcicutils/structured_data.py @@ -885,12 +885,7 @@ def ref_exists(self, type_name: str, value: Optional[str] = None, # self._data can change, i.e. as data (e.g. spreadsheet sheets) are parsed. return self.ref_exists_internally(type_name, value, update_counts=called_from_map_ref) or {} # Reference is NOT cached here; lookup INTERNALLY first. - if (resolved := self.ref_exists_internally(type_name, value, update_counts=called_from_map_ref)) is None: - # Reference was resolved (internally) INCORRECTLY. - if called_from_map_ref: - self._ref_total_notfound_count += 1 - return None - if resolved: + if resolved := self.ref_exists_internally(type_name, value, update_counts=called_from_map_ref): # Reference was resolved internally (note: here only if resolved is not an empty dictionary). if called_from_map_ref: self._ref_total_found_count += 1 @@ -939,15 +934,14 @@ def ref_exists_internally(self, type_name: str, value: Optional[str] = None, update_counts: bool = False) -> Optional[dict]: """ Looks up the given reference (type/value) internally (i.e. with this data parsed thus far). - If found then returns a list of a single dictionary containing the (given) type name and - the uuid (if any) of the resolved item. If not found then returns an empty list; however, - if not found, but found using an invalid identifying property, then returns None. + If found then returns a dictionary containing the (given) type name and the uuid (if any) + of the resolved item. """ # print(f"\033[Kxyzzy:ref_exists_internally({type_name}/{value})") if not value: type_name, value = Portal._get_type_name_and_value_from_path(type_name) if not type_name or not value: - return None + return None # Should not happen. # Note that root lookup not applicable here. ref_lookup_strategy, ref_validator = ( self._ref_lookup_strategy(type_name, self.get_schema(type_name), value)) @@ -1038,8 +1032,8 @@ def _ref_exists_from_cache(self, type_name: str, value: str) -> Optional[List[di return None def _cache_ref(self, type_name: str, value: str, resolved: List[str]) -> None: - subtype_names = self._get_schema_subtypes_names(type_name) if self._ref_cache is not None: + subtype_names = self._get_schema_subtypes_names(type_name) for type_name in [type_name] + subtype_names: self._ref_cache[f"/{type_name}/{value}"] = resolved diff --git a/pyproject.toml b/pyproject.toml index 40805b87e..aa2cf07fb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "dcicutils" -version = "8.8.0.1b21" # TODO: To become 8.8.1 +version = "8.8.0.1b22" # TODO: To become 8.8.1 description = "Utility package for interacting with the 4DN Data Portal and other 4DN resources" authors = ["4DN-DCIC Team "] license = "MIT"