From eb08cc4768293faca82bf3f1a60c02d105249e20 Mon Sep 17 00:00:00 2001 From: GeneCodeSavvy Date: Mon, 3 Mar 2025 00:47:55 +0530 Subject: [PATCH 1/5] range replaced with enumerate --- sbol3/toplevel.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sbol3/toplevel.py b/sbol3/toplevel.py index 7cca28d..46f4e45 100644 --- a/sbol3/toplevel.py +++ b/sbol3/toplevel.py @@ -3,11 +3,11 @@ import copy import math import posixpath +import typing import urllib.parse import uuid import warnings -from typing import Dict, Callable, Optional, Any -import typing +from typing import Any, Callable, Dict, Optional from . import * from .typing import * @@ -234,10 +234,10 @@ def update_references_traverser(x): if v.property_uri not in x._properties: continue items = x._properties[v.property_uri] - for i in range(len(items)): - str_item = str(items[i]) - if str_item in identity_map: - new_reference = identity_map[str_item].identity + for i, item in enumerate(items): + str_item = str(item) + if str(item) in identity_map: + new_reference = identity_map[str(item)].identity # The item is probably an rdflib.URIRef. We take # the type of the item and use that type to # construct a new instance of the same type. From d0157b00775e95ec6dc87010ab543f8ff547b9d4 Mon Sep 17 00:00:00 2001 From: GeneCodeSavvy Date: Mon, 3 Mar 2025 01:28:31 +0530 Subject: [PATCH 2/5] test files --- test/test_component.py | 3 +-- test/test_module.py | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/test/test_component.py b/test/test_component.py index 8486d92..846f030 100644 --- a/test/test_component.py +++ b/test/test_component.py @@ -148,8 +148,7 @@ def test_cloning_references(self): doc2 = sbol3.Document() doc2.add(toggle_clone) self.assertEqual(len(toggle.constraints), len(toggle_clone.constraints)) - for i in range(len(toggle.constraints)): - c = toggle.constraints[i] + for i, c in enumerate(toggle.constraints): c_clone = toggle_clone.constraints[i] self.assertNotEqual(c.identity, c_clone.identity) s = c.subject.lookup() diff --git a/test/test_module.py b/test/test_module.py index d315266..acee7ef 100644 --- a/test/test_module.py +++ b/test/test_module.py @@ -100,9 +100,9 @@ def test_identified_constructors(self): try: item(*arg_list) except TypeError as e: - self.fail('Unable to construct sbol3.%s: %s' % (name, e)) + self.fail(f'Unable to construct sbol3.{name}: {e}') except sbol3.ValidationError as e: - self.fail('Constructed invalid sbol3.%s: %s' % (name, e)) + self.fail(f'Constructed invalid sbol3.{name}: {e}') if item in abstract_list: # Skip over abstract classes when checking for the # accept method From a4179728cab76bc8c0eda88c35e4310944af29c8 Mon Sep 17 00:00:00 2001 From: GeneCodeSavvy Date: Mon, 3 Mar 2025 01:35:50 +0530 Subject: [PATCH 3/5] revert test/test_module.py --- test/test_module.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_module.py b/test/test_module.py index acee7ef..d315266 100644 --- a/test/test_module.py +++ b/test/test_module.py @@ -100,9 +100,9 @@ def test_identified_constructors(self): try: item(*arg_list) except TypeError as e: - self.fail(f'Unable to construct sbol3.{name}: {e}') + self.fail('Unable to construct sbol3.%s: %s' % (name, e)) except sbol3.ValidationError as e: - self.fail(f'Constructed invalid sbol3.{name}: {e}') + self.fail('Constructed invalid sbol3.%s: %s' % (name, e)) if item in abstract_list: # Skip over abstract classes when checking for the # accept method From e024fbcd668c3a7ead7e12ce989bd48733a386d3 Mon Sep 17 00:00:00 2001 From: GeneCodeSavvy Date: Mon, 3 Mar 2025 23:17:47 +0530 Subject: [PATCH 4/5] update setup.cfg --- setup.cfg | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 3cf21b6..be0b274 100644 --- a/setup.cfg +++ b/setup.cfg @@ -20,7 +20,6 @@ disable = abstract-class-instantiated, implicit-str-concat, import-outside-toplevel, logging-not-lazy, - consider-using-enumerate, consider-using-f-string, cyclic-import, duplicate-code, From 625cfd03b5febccce9cc685bc94e69864a0aba03 Mon Sep 17 00:00:00 2001 From: GeneCodeSavvy Date: Mon, 3 Mar 2025 23:23:12 +0530 Subject: [PATCH 5/5] cleanup --- sbol3/toplevel.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sbol3/toplevel.py b/sbol3/toplevel.py index 46f4e45..a892ed3 100644 --- a/sbol3/toplevel.py +++ b/sbol3/toplevel.py @@ -236,8 +236,8 @@ def update_references_traverser(x): items = x._properties[v.property_uri] for i, item in enumerate(items): str_item = str(item) - if str(item) in identity_map: - new_reference = identity_map[str(item)].identity + if str_item in identity_map: + new_reference = identity_map[str_item].identity # The item is probably an rdflib.URIRef. We take # the type of the item and use that type to # construct a new instance of the same type.