From 7754655a075440da4e46307f2e401b25512d8bb5 Mon Sep 17 00:00:00 2001 From: Ken Kroenlein Date: Mon, 18 Dec 2023 06:59:34 -0700 Subject: [PATCH 01/10] Boost max testing version to 3.12 --- .travis.yml | 3 ++- setup.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a608294d..8330fa6e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,11 @@ language: python -dist: bionic +dist: jammy python: - '3.8' - '3.9' - '3.10' - '3.11' +- '3.12' env: - UPGRADES="-U pint pandas" - UPGRADES="" diff --git a/setup.py b/setup.py index b753863c..8159dd1e 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ packages.append("") setup(name='gemd', - version='1.16.8', + version='1.16.9', python_requires='>=3.8', url='http://github.com/CitrineInformatics/gemd-python', description="Python binding for Citrine's GEMD data model", @@ -43,5 +43,6 @@ 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', ], ) From 55e930f216e212a3e4d179e54320ccfd1a94ca9c Mon Sep 17 00:00:00 2001 From: Ken Kroenlein Date: Mon, 18 Dec 2023 07:14:17 -0700 Subject: [PATCH 02/10] Correct minimum Pandas version in testing --- test_requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_requirements.txt b/test_requirements.txt index 4264feee..23cab842 100644 --- a/test_requirements.txt +++ b/test_requirements.txt @@ -2,7 +2,7 @@ flake8==3.7.8 flake8-docstrings==1.3.1 pytest==7.3.1 pytest-cov==4.0.0 -pandas==1.5.0 +pandas==1.5.3 toolz==0.12.0 derp==0.1.1 sphinx==4.3.0 From 9c49dddecf6335564233f5d39c1c00f4f525fc49 Mon Sep 17 00:00:00 2001 From: Ken Kroenlein Date: Mon, 18 Dec 2023 07:29:23 -0700 Subject: [PATCH 03/10] Swap from Jammy to Focal because of Python 3.10 version --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8330fa6e..f03d9a9a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: python -dist: jammy +dist: focal python: - '3.8' - '3.9' From dc85d903c947bb7b660cdb0df2c3bc05ac0c2d32 Mon Sep 17 00:00:00 2001 From: Ken Kroenlein Date: Mon, 18 Dec 2023 08:20:52 -0700 Subject: [PATCH 04/10] Skip low-version build w/ 3.12 (pandas issues) --- .travis.yml | 7 ++++++- test_requirements.txt | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f03d9a9a..9f917901 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,10 +9,15 @@ python: env: - UPGRADES="-U pint pandas" - UPGRADES="" +jobs: + exclude: + - python: '3.12' + env: UPGRADES="" install: - pip install --only-binary ':all:' -r requirements.txt + - test $TRAVIS_PYTHON_VERSION == "3.12" || perl -pi -E 's/^.*pandas.*$//' test_requirements.txt - pip install --only-binary ':all:' -r test_requirements.txt - - pip install $UPGRADES -e . + - pip install $UPGRADES -e .d script: - bash scripts/run_tests.sh - test "$UPGRADES" != "" || test $TRAVIS_PYTHON_VERSION != "3.10" || bash scripts/build_docs.sh diff --git a/test_requirements.txt b/test_requirements.txt index 23cab842..3a3eebe3 100644 --- a/test_requirements.txt +++ b/test_requirements.txt @@ -2,7 +2,7 @@ flake8==3.7.8 flake8-docstrings==1.3.1 pytest==7.3.1 pytest-cov==4.0.0 -pandas==1.5.3 + toolz==0.12.0 derp==0.1.1 sphinx==4.3.0 From 2d8603cd91598a813701c2fe1b0ff1315f4d3684 Mon Sep 17 00:00:00 2001 From: Ken Kroenlein Date: Mon, 18 Dec 2023 08:26:03 -0700 Subject: [PATCH 05/10] Enforce that upgraded libraries are still binaries --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9f917901..c1450e5f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ python: - '3.11' - '3.12' env: - - UPGRADES="-U pint pandas" + - UPGRADES="-U '--only-binary=pint,pandas' pint pandas" - UPGRADES="" jobs: exclude: @@ -17,7 +17,7 @@ install: - pip install --only-binary ':all:' -r requirements.txt - test $TRAVIS_PYTHON_VERSION == "3.12" || perl -pi -E 's/^.*pandas.*$//' test_requirements.txt - pip install --only-binary ':all:' -r test_requirements.txt - - pip install $UPGRADES -e .d + - pip install $UPGRADES -e . script: - bash scripts/run_tests.sh - test "$UPGRADES" != "" || test $TRAVIS_PYTHON_VERSION != "3.10" || bash scripts/build_docs.sh From add7f50c7526e7d62b26f99c39e361d4a90780c4 Mon Sep 17 00:00:00 2001 From: Ken Kroenlein Date: Mon, 18 Dec 2023 08:33:27 -0700 Subject: [PATCH 06/10] Correct typo --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c1450e5f..db1f067a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ python: - '3.11' - '3.12' env: - - UPGRADES="-U '--only-binary=pint,pandas' pint pandas" + - UPGRADES="-U '--only-binary==pint,pandas' pint pandas" - UPGRADES="" jobs: exclude: From 6fdfe997028560b4529eba3dbec0c57fa1ebaa46 Mon Sep 17 00:00:00 2001 From: Ken Kroenlein Date: Mon, 18 Dec 2023 08:38:33 -0700 Subject: [PATCH 07/10] Correct typo --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index db1f067a..95fbc4e5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ python: - '3.11' - '3.12' env: - - UPGRADES="-U '--only-binary==pint,pandas' pint pandas" + - UPGRADES="-U --only-binary 'pint,pandas' pint pandas" - UPGRADES="" jobs: exclude: From ea38da8a28559e2affcc8ba52180631f2568b6e1 Mon Sep 17 00:00:00 2001 From: Ken Kroenlein Date: Mon, 18 Dec 2023 10:18:36 -0700 Subject: [PATCH 08/10] travis configuration --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 95fbc4e5..f0609cbb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ jobs: env: UPGRADES="" install: - pip install --only-binary ':all:' -r requirements.txt - - test $TRAVIS_PYTHON_VERSION == "3.12" || perl -pi -E 's/^.*pandas.*$//' test_requirements.txt + - test $TRAVIS_PYTHON_VERSION != "3.12" || perl -pi -E 's/^.*pandas.*$//' test_requirements.txt - pip install --only-binary ':all:' -r test_requirements.txt - pip install $UPGRADES -e . script: From e2141e620eef998c2bc2bbd9f4cbd67d4a209085 Mon Sep 17 00:00:00 2001 From: Ken Kroenlein Date: Mon, 18 Dec 2023 10:27:53 -0700 Subject: [PATCH 09/10] Repair test_requirements.txt --- test_requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_requirements.txt b/test_requirements.txt index 3a3eebe3..4264feee 100644 --- a/test_requirements.txt +++ b/test_requirements.txt @@ -2,7 +2,7 @@ flake8==3.7.8 flake8-docstrings==1.3.1 pytest==7.3.1 pytest-cov==4.0.0 - +pandas==1.5.0 toolz==0.12.0 derp==0.1.1 sphinx==4.3.0 From 94b3f5833afdf561c55cfb20ae7982d9438c5ad6 Mon Sep 17 00:00:00 2001 From: Ken Kroenlein Date: Mon, 18 Dec 2023 15:02:54 -0700 Subject: [PATCH 10/10] Upgrade flake8 for python 3.12 support --- .travis.yml | 2 +- gemd/demo/strehlow_and_cook.py | 4 ++-- gemd/entity/base_entity.py | 2 +- gemd/entity/bounds/base_bounds.py | 6 +++--- gemd/entity/bounds/categorical_bounds.py | 8 ++++---- gemd/entity/bounds/composition_bounds.py | 8 ++++---- gemd/entity/bounds/integer_bounds.py | 8 +++++--- gemd/entity/bounds/molecular_structure_bounds.py | 8 ++++---- gemd/entity/bounds/real_bounds.py | 6 +++--- gemd/entity/dict_serializable.py | 4 ++-- gemd/entity/has_dependencies.py | 2 +- gemd/entity/object/has_conditions.py | 2 +- gemd/entity/object/has_material.py | 2 +- gemd/entity/object/has_parameters.py | 2 +- gemd/entity/object/has_process.py | 2 +- gemd/entity/object/has_properties.py | 2 +- gemd/entity/object/has_spec.py | 2 +- gemd/entity/object/has_template.py | 2 +- gemd/entity/object/material_run.py | 2 +- gemd/entity/object/process_run.py | 4 ++-- gemd/entity/object/process_spec.py | 2 +- gemd/entity/template/has_condition_templates.py | 2 +- gemd/entity/template/has_parameter_templates.py | 2 +- gemd/entity/template/has_property_templates.py | 6 ++++-- gemd/util/impl.py | 2 +- test_requirements.txt | 4 ++-- 26 files changed, 50 insertions(+), 46 deletions(-) diff --git a/.travis.yml b/.travis.yml index f0609cbb..ab4cb1ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ jobs: env: UPGRADES="" install: - pip install --only-binary ':all:' -r requirements.txt - - test $TRAVIS_PYTHON_VERSION != "3.12" || perl -pi -E 's/^.*pandas.*$//' test_requirements.txt + - test $TRAVIS_PYTHON_VERSION != "3.12" || perl -pi -E 's/^.*(?:pandas|flake8-docstrings).*$//' test_requirements.txt - pip install --only-binary ':all:' -r test_requirements.txt - pip install $UPGRADES -e . script: diff --git a/gemd/demo/strehlow_and_cook.py b/gemd/demo/strehlow_and_cook.py index e89d6f59..389b9ab9 100644 --- a/gemd/demo/strehlow_and_cook.py +++ b/gemd/demo/strehlow_and_cook.py @@ -289,7 +289,7 @@ def real_mapper(prop): template = tmpl[name_map[attr['name']]] # Move into GEMD structure - if type(template) == PropertyTemplate: + if isinstance(template, PropertyTemplate): msr.properties.append( Property(name=template.name, template=template, @@ -297,7 +297,7 @@ def real_mapper(prop): origin=origin, notes=method )) - elif type(template) == ConditionTemplate: + elif isinstance(template, ConditionTemplate): msr.conditions.append( Condition(name=template.name, template=template, diff --git a/gemd/entity/base_entity.py b/gemd/entity/base_entity.py index 40a1bd23..c1d72289 100644 --- a/gemd/entity/base_entity.py +++ b/gemd/entity/base_entity.py @@ -100,7 +100,7 @@ def to_link(self, return LinkByUID(scope=scope, id=uid) - def all_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]: + def all_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]: # noqa: F821 """Return a set of all immediate dependencies (no recursion).""" result = set() queue = [type(self)] diff --git a/gemd/entity/bounds/base_bounds.py b/gemd/entity/bounds/base_bounds.py index 0453e817..fb6b4236 100644 --- a/gemd/entity/bounds/base_bounds.py +++ b/gemd/entity/bounds/base_bounds.py @@ -9,7 +9,7 @@ class BaseBounds(DictSerializable): """Base class for bounds, including RealBounds and CategoricalBounds.""" @abstractmethod - def contains(self, bounds: Union["BaseBounds", "BaseValue"]): + def contains(self, bounds: Union["BaseBounds", "BaseValue"]): # noqa: F821 """ Check if another bounds is contained within this bounds. @@ -36,7 +36,7 @@ def contains(self, bounds: Union["BaseBounds", "BaseValue"]): raise TypeError('{} is not a Bounds object'.format(bounds)) @abstractmethod - def union(self, *others: Union["BaseBounds", "BaseValue"]) -> "BaseBounds": + def union(self, *others: Union["BaseBounds", "BaseValue"]) -> "BaseBounds": # noqa: F821 """ Return the union of this bounds and other bounds. @@ -56,7 +56,7 @@ def union(self, *others: Union["BaseBounds", "BaseValue"]) -> "BaseBounds": pass # pragma: no cover @abstractmethod - def update(self, *others: Union["BaseBounds", "BaseValue"]): + def update(self, *others: Union["BaseBounds", "BaseValue"]): # noqa: F821 """ Update this bounds to include other bounds. diff --git a/gemd/entity/bounds/categorical_bounds.py b/gemd/entity/bounds/categorical_bounds.py index c2c8caa4..bad59205 100644 --- a/gemd/entity/bounds/categorical_bounds.py +++ b/gemd/entity/bounds/categorical_bounds.py @@ -39,7 +39,7 @@ def categories(self, categories: Optional[Iterable[str]]): if not all(isinstance(x, str) for x in self.categories): raise ValueError("All the categories must be strings") - def contains(self, bounds: Union[BaseBounds, "BaseValue"]) -> bool: + def contains(self, bounds: Union[BaseBounds, "BaseValue"]) -> bool: # noqa: F821 """ Check if another bounds object or value objects is contained by this bounds. @@ -69,8 +69,8 @@ def contains(self, bounds: Union[BaseBounds, "BaseValue"]) -> bool: return bounds.categories.issubset(self.categories) def union(self, - *others: Union["CategoricalBounds", "CategoricalValue"] - ) -> "CategoricalBounds": + *others: Union["CategoricalBounds", "CategoricalValue"] # noqa: F821 + ) -> "CategoricalBounds": # noqa: F821 """ Return the union of this bounds and other bounds. @@ -102,7 +102,7 @@ def union(self, result.update(bounds.categories) return CategoricalBounds(result) - def update(self, *others: Union["CategoricalBounds", "CategoricalValue"]): + def update(self, *others: Union["CategoricalBounds", "CategoricalValue"]): # noqa: F821 """ Update this bounds to include other bounds. diff --git a/gemd/entity/bounds/composition_bounds.py b/gemd/entity/bounds/composition_bounds.py index e00de515..db399d5c 100644 --- a/gemd/entity/bounds/composition_bounds.py +++ b/gemd/entity/bounds/composition_bounds.py @@ -39,7 +39,7 @@ def components(self, value): if not all(isinstance(x, str) for x in self.components): raise ValueError("All the components must be strings") - def contains(self, bounds: Union[BaseBounds, "BaseValue"]) -> bool: + def contains(self, bounds: Union[BaseBounds, "BaseValue"]) -> bool: # noqa: F821 """ Check if another bounds or value object is contained by this bounds. @@ -69,8 +69,8 @@ def contains(self, bounds: Union[BaseBounds, "BaseValue"]) -> bool: return bounds.components.issubset(self.components) def union(self, - *others: Union["CompositionBounds", "CompositionValue"] - ) -> "CompositionBounds": + *others: Union["CompositionBounds", "CompositionValue"] # noqa: F821 + ) -> "CompositionBounds": # noqa: F821 """ Return the union of this bounds and other bounds. @@ -102,7 +102,7 @@ def union(self, result.update(bounds.components) return CompositionBounds(result) - def update(self, *others: Union["CompositionBounds", "CompositionValue"]): + def update(self, *others: Union["CompositionBounds", "CompositionValue"]): # noqa: F821 """ Update this bounds to include other bounds. diff --git a/gemd/entity/bounds/integer_bounds.py b/gemd/entity/bounds/integer_bounds.py index 3f37f8c8..7c8f0ef3 100644 --- a/gemd/entity/bounds/integer_bounds.py +++ b/gemd/entity/bounds/integer_bounds.py @@ -30,7 +30,7 @@ def __init__(self, lower_bound=None, upper_bound=None): if self.upper_bound < self.lower_bound: raise ValueError("Upper bound must be greater than or equal to lower bound") - def contains(self, bounds: Union[BaseBounds, "BaseValue"]) -> bool: + def contains(self, bounds: Union[BaseBounds, "BaseValue"]) -> bool: # noqa: F821 """ Check if another bounds or value object is a subset of this range. @@ -59,7 +59,9 @@ def contains(self, bounds: Union[BaseBounds, "BaseValue"]) -> bool: return bounds.lower_bound >= self.lower_bound and bounds.upper_bound <= self.upper_bound - def union(self, *others: Union["IntegerBounds", "IntegerValue"]) -> "IntegerBounds": + def union(self, + *others: Union["IntegerBounds", "IntegerValue"] # noqa: F821 + ) -> "IntegerBounds": # noqa: F821 """ Return the union of this bounds and other bounds. @@ -94,7 +96,7 @@ def union(self, *others: Union["IntegerBounds", "IntegerValue"]) -> "IntegerBoun upper = bounds.upper_bound return IntegerBounds(lower_bound=lower, upper_bound=upper) - def update(self, *others: Union["IntegerBounds", "IntegerValue"]): + def update(self, *others: Union["IntegerBounds", "IntegerValue"]): # noqa: F821 """ Update this bounds to include other bounds. diff --git a/gemd/entity/bounds/molecular_structure_bounds.py b/gemd/entity/bounds/molecular_structure_bounds.py index 43838c81..de08b369 100644 --- a/gemd/entity/bounds/molecular_structure_bounds.py +++ b/gemd/entity/bounds/molecular_structure_bounds.py @@ -11,7 +11,7 @@ class MolecularStructureBounds(BaseBounds, typ="molecular_structure_bounds"): """Molecular bounds, with no component or substructural restrictions (yet).""" - def contains(self, bounds: Union[BaseBounds, "BaseValue"]) -> bool: + def contains(self, bounds: Union[BaseBounds, "BaseValue"]) -> bool: # noqa: F821 """ Check if another bounds or value object is contained by this bounds. @@ -41,8 +41,8 @@ def contains(self, bounds: Union[BaseBounds, "BaseValue"]) -> bool: return True def union(self, - *others: Union["MolecularStructureBounds", "MolecularValue"] - ) -> "MolecularStructureBounds": + *others: Union["MolecularStructureBounds", "MolecularValue"] # noqa: F821 + ) -> "MolecularStructureBounds": # noqa: F821 """ Return the union of this bounds and other bounds. @@ -69,7 +69,7 @@ def union(self, f"expected molecular structure, found {misses}") return MolecularStructureBounds() - def update(self, *others: Union["MolecularStructureBounds", "MolecularValue"]): + def update(self, *others: Union["MolecularStructureBounds", "MolecularValue"]): # noqa: F821 """ Update this bounds to include other bounds. diff --git a/gemd/entity/bounds/real_bounds.py b/gemd/entity/bounds/real_bounds.py index db8981e6..c49c9455 100644 --- a/gemd/entity/bounds/real_bounds.py +++ b/gemd/entity/bounds/real_bounds.py @@ -49,7 +49,7 @@ def default_units(self, default_units): "Use an empty string for a dimensionless quantity.") self._default_units = units.parse_units(default_units) - def contains(self, bounds: Union[BaseBounds, "BaseValue"]) -> bool: + def contains(self, bounds: Union[BaseBounds, "BaseValue"]) -> bool: # noqa: F821 """ Check if another bounds or value object is a subset of this range. @@ -84,7 +84,7 @@ def contains(self, bounds: Union[BaseBounds, "BaseValue"]) -> bool: return bounds.lower_bound >= lower and bounds.upper_bound <= upper - def union(self, *others: Union["RealBounds", "ContinuousValue"]) -> "RealBounds": + def union(self, *others: Union["RealBounds", "ContinuousValue"]) -> "RealBounds": # noqa: F821 """ Return the union of this bounds and other bounds. @@ -123,7 +123,7 @@ def union(self, *others: Union["RealBounds", "ContinuousValue"]) -> "RealBounds" upper = bnd_hi return RealBounds(lower_bound=lower, upper_bound=upper, default_units=unit_) - def update(self, *others: Union["RealBounds", "ContinuousValue"]): + def update(self, *others: Union["RealBounds", "ContinuousValue"]): # noqa: F821 """ Update this bounds to include other bounds. diff --git a/gemd/entity/dict_serializable.py b/gemd/entity/dict_serializable.py index 0994222b..02ff6290 100644 --- a/gemd/entity/dict_serializable.py +++ b/gemd/entity/dict_serializable.py @@ -18,9 +18,9 @@ class DictSerializableMeta(ABCMeta): _class: Dict[str, type] = {} - def __new__(mcs, name, bases, *args, + def __new__(mcs, name, bases, *args, # noqa: D102 typ: str = None, skip: Set[str] = frozenset(), - **kwargs): # noqa: D102 + **kwargs): return super().__new__(mcs, name, bases, *args, **kwargs) def __init__(cls, name, bases, *args, typ: str = None, skip: Set[str] = frozenset(), **kwargs): diff --git a/gemd/entity/has_dependencies.py b/gemd/entity/has_dependencies.py index 14ab166b..87b6f4e0 100644 --- a/gemd/entity/has_dependencies.py +++ b/gemd/entity/has_dependencies.py @@ -7,5 +7,5 @@ class HasDependencies(ABC): """Mix-in trait for objects that reference other objects.""" @abstractmethod - def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]: + def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]: # noqa: F821 """All dependencies (objects) that this class introduces.""" diff --git a/gemd/entity/object/has_conditions.py b/gemd/entity/object/has_conditions.py index f37e3560..e0287407 100644 --- a/gemd/entity/object/has_conditions.py +++ b/gemd/entity/object/has_conditions.py @@ -34,6 +34,6 @@ def conditions(self, conditions: Union[Condition, Iterable[Condition]]): checker = self._generate_template_check(HasConditionTemplates.validate_condition) self._conditions = validate_list(conditions, Condition, trigger=checker) - def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]: + def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]: # noqa: F821 """Return a set of all immediate dependencies (no recursion).""" return {cond.template for cond in self.conditions if cond.template is not None} diff --git a/gemd/entity/object/has_material.py b/gemd/entity/object/has_material.py index 5ba58c7d..7a9d5f5b 100644 --- a/gemd/entity/object/has_material.py +++ b/gemd/entity/object/has_material.py @@ -20,6 +20,6 @@ def material(self) -> Union[BaseObject, LinkByUID]: def material(self, spec: Union[BaseObject, LinkByUID]): """Set the material.""" - def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]: + def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]: # noqa: F821 """Return a set of all immediate dependencies (no recursion).""" return {self.material} if self.material is not None else set() diff --git a/gemd/entity/object/has_parameters.py b/gemd/entity/object/has_parameters.py index d6168a42..28a18e67 100644 --- a/gemd/entity/object/has_parameters.py +++ b/gemd/entity/object/has_parameters.py @@ -34,6 +34,6 @@ def parameters(self, parameters: Union[Parameter, Iterable[Parameter]]): checker = self._generate_template_check(HasParameterTemplates.validate_parameter) self._parameters = validate_list(parameters, Parameter, trigger=checker) - def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]: + def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]: # noqa: F821 """Return a set of all immediate dependencies (no recursion).""" return {param.template for param in self.parameters if param.template is not None} diff --git a/gemd/entity/object/has_process.py b/gemd/entity/object/has_process.py index 5f029483..d26b05d8 100644 --- a/gemd/entity/object/has_process.py +++ b/gemd/entity/object/has_process.py @@ -20,6 +20,6 @@ def process(self) -> Union[BaseObject, LinkByUID]: def process(self, process: Union[BaseObject, LinkByUID]): """Set the process.""" - def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]: + def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]: # noqa: F821 """Return a set of all immediate dependencies (no recursion).""" return {self.process} if self.process is not None else set() diff --git a/gemd/entity/object/has_properties.py b/gemd/entity/object/has_properties.py index 307c4808..d247db9e 100644 --- a/gemd/entity/object/has_properties.py +++ b/gemd/entity/object/has_properties.py @@ -34,6 +34,6 @@ def properties(self, properties: Union[Property, Iterable[Property]]): checker = self._generate_template_check(HasPropertyTemplates.validate_property) self._properties = validate_list(properties, Property, trigger=checker) - def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]: + def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]: # noqa: F821 """Return a set of all immediate dependencies (no recursion).""" return {prop.template for prop in self.properties if prop.template is not None} diff --git a/gemd/entity/object/has_spec.py b/gemd/entity/object/has_spec.py index 6e50cc53..d91ca213 100644 --- a/gemd/entity/object/has_spec.py +++ b/gemd/entity/object/has_spec.py @@ -51,6 +51,6 @@ def template(self) -> Optional[Union[BaseTemplate, LinkByUID]]: else: return None - def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]: + def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]: # noqa: F821 """Return a set of all immediate dependencies (no recursion).""" return {self.spec} if self.spec is not None else set() diff --git a/gemd/entity/object/has_template.py b/gemd/entity/object/has_template.py index f69d684f..c968f9fa 100644 --- a/gemd/entity/object/has_template.py +++ b/gemd/entity/object/has_template.py @@ -42,6 +42,6 @@ def template(self, template: Optional[Union[BaseTemplate, LinkByUID]]): raise TypeError(f"Template must be a {self._template_type()} or LinkByUID, " f"not {type(template)}") - def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]: + def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]: # noqa: F821 """Return a set of all immediate dependencies (no recursion).""" return {self.template} if self.template is not None else set() diff --git a/gemd/entity/object/material_run.py b/gemd/entity/object/material_run.py index 3531af0e..5d4a5348 100644 --- a/gemd/entity/object/material_run.py +++ b/gemd/entity/object/material_run.py @@ -91,7 +91,7 @@ def process(self, process: Union[ProcessRun, LinkByUID]): raise TypeError("process must be a ProcessRun or LinkByUID: {}".format(process)) @property - def measurements(self) -> List["MeasurementRun"]: + def measurements(self) -> List["MeasurementRun"]: # noqa: F821 """Get a read-only list of the measurement runs.""" return self._measurements diff --git a/gemd/entity/object/process_run.py b/gemd/entity/object/process_run.py index 47209d91..eb72cfca 100644 --- a/gemd/entity/object/process_run.py +++ b/gemd/entity/object/process_run.py @@ -86,12 +86,12 @@ def __init__(self, self._output_material = None @property - def output_material(self) -> Optional["MaterialRun"]: + def output_material(self) -> Optional["MaterialRun"]: # noqa: F821 """Get the output material run.""" return self._output_material @property - def ingredients(self) -> List["IngredientRun"]: + def ingredients(self) -> List["IngredientRun"]: # noqa: F821 """Get the input ingredient runs.""" return self._ingredients diff --git a/gemd/entity/object/process_spec.py b/gemd/entity/object/process_spec.py index 2943ce84..ac5039ac 100644 --- a/gemd/entity/object/process_spec.py +++ b/gemd/entity/object/process_spec.py @@ -90,7 +90,7 @@ def _template_type() -> Type: return ProcessTemplate @property - def ingredients(self) -> List["IngredientSpec"]: + def ingredients(self) -> List["IngredientSpec"]: # noqa: F821 """Get the list of input ingredient specs.""" return self._ingredients diff --git a/gemd/entity/template/has_condition_templates.py b/gemd/entity/template/has_condition_templates.py index 98cc54c0..927b6795 100644 --- a/gemd/entity/template/has_condition_templates.py +++ b/gemd/entity/template/has_condition_templates.py @@ -83,6 +83,6 @@ def validate_condition(self, condition: "Condition") -> bool: # noqa: F821 else: return True # Nothing to check against - def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]: + def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]: # noqa: F821 """Return a set of all immediate dependencies (no recursion).""" return {attr[0] for attr in self.conditions} diff --git a/gemd/entity/template/has_parameter_templates.py b/gemd/entity/template/has_parameter_templates.py index 3d5f062e..29288b41 100644 --- a/gemd/entity/template/has_parameter_templates.py +++ b/gemd/entity/template/has_parameter_templates.py @@ -83,6 +83,6 @@ def validate_parameter(self, parameter: "Parameter") -> bool: # noqa: F821 else: return True # Nothing to check against - def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]: + def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]: # noqa: F821 """Return a set of all immediate dependencies (no recursion).""" return {attr[0] for attr in self.parameters} diff --git a/gemd/entity/template/has_property_templates.py b/gemd/entity/template/has_property_templates.py index 2e15cd89..5cb6810e 100644 --- a/gemd/entity/template/has_property_templates.py +++ b/gemd/entity/template/has_property_templates.py @@ -63,7 +63,9 @@ def properties(self, properties: Iterable[Union[Union[PropertyTemplate, LinkByUI trigger=BaseTemplate._homogenize_ranges ) - def validate_property(self, prop: Union["Property", "PropertyAndConditions"]) -> bool: + def validate_property(self, + prop: Union["Property", "PropertyAndConditions"] # noqa: F821 + ) -> bool: # noqa: F821 """Check if the property is consistent w/ this template.""" from gemd.entity.attribute import PropertyAndConditions if isinstance(prop, PropertyAndConditions): @@ -83,6 +85,6 @@ def validate_property(self, prop: Union["Property", "PropertyAndConditions"]) -> else: return True # Nothing to check against - def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]: + def _local_dependencies(self) -> Set[Union["BaseEntity", "LinkByUID"]]: # noqa: F821 """Return a set of all immediate dependencies (no recursion).""" return {attr[0] for attr in self.properties} diff --git a/gemd/util/impl.py b/gemd/util/impl.py index b06c3862..64f64acb 100644 --- a/gemd/util/impl.py +++ b/gemd/util/impl.py @@ -338,7 +338,7 @@ def substitute_objects(obj, method = _substitute return method(obj, - sub=lambda l: index.get(l, l), + sub=lambda link: index.get(link, link), applies=lambda o: cached_isinstance(o, LinkByUID)) diff --git a/test_requirements.txt b/test_requirements.txt index 4264feee..8d88ee33 100644 --- a/test_requirements.txt +++ b/test_requirements.txt @@ -1,5 +1,5 @@ -flake8==3.7.8 -flake8-docstrings==1.3.1 +flake8==6.1.0 +flake8-docstrings==1.7.0 pytest==7.3.1 pytest-cov==4.0.0 pandas==1.5.0