Skip to content

Commit

Permalink
Reduce complexity of is_inherited_spec
Browse files Browse the repository at this point in the history
  • Loading branch information
rly authored Feb 8, 2025
1 parent 1071f54 commit 5e6a4b3
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions src/hdmf/spec/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -1045,24 +1045,20 @@ def is_inherited_spec(self, **kwargs):
return self.is_inherited_type(spec_name)
elif spec_name in self.__target_types:
return self.is_inherited_target_type(spec_name)
elif super().is_inherited_spec(spec): # attribute spec
return True
else:
# attribute spec
if super().is_inherited_spec(spec):
return True
parent_name = spec.parent.name
if parent_name is None:
parent_name = spec.parent.data_type
if isinstance(spec.parent, DatasetSpec):
if (parent_name in self.__datasets and self.is_inherited_dataset(parent_name) and
self.__datasets[parent_name].get_attribute(spec_name) is not None):
return True
else:
parent_name = spec.parent.name
if parent_name is None:
parent_name = spec.parent.data_type
if isinstance(spec.parent, DatasetSpec):
if parent_name in self.__datasets:
if self.is_inherited_dataset(parent_name):
if self.__datasets[parent_name].get_attribute(spec_name) is not None:
return True
else:
if parent_name in self.__groups:
if self.is_inherited_group(parent_name):
if self.__groups[parent_name].get_attribute(spec_name) is not None:
return True
if (parent_name in self.__groups and self.is_inherited_group(parent_name) and :

Check failure on line 1059 in src/hdmf/spec/spec.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff

src/hdmf/spec/spec.py:1059:95: SyntaxError: Expected an expression
self.__groups[parent_name].get_attribute(spec_name) is not None):

Check failure on line 1060 in src/hdmf/spec/spec.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff

src/hdmf/spec/spec.py:1060:84: SyntaxError: Expected newline, found ')'

Check failure on line 1060 in src/hdmf/spec/spec.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff

src/hdmf/spec/spec.py:1060:85: SyntaxError: Expected a statement
return True

Check failure on line 1061 in src/hdmf/spec/spec.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff

src/hdmf/spec/spec.py:1060:86: SyntaxError: Expected a statement

Check failure on line 1061 in src/hdmf/spec/spec.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff

src/hdmf/spec/spec.py:1061:1: SyntaxError: Unexpected indentation
return False

@docval({'name': 'spec', 'type': Spec, 'doc': 'the specification to check'})
Expand Down

0 comments on commit 5e6a4b3

Please sign in to comment.