From 285b6e4d974b0471ce3cdfc74eff3a97ddf38b1c Mon Sep 17 00:00:00 2001 From: GeneCodeSavvy Date: Fri, 28 Feb 2025 12:17:13 +0530 Subject: [PATCH 1/9] document.py --- sbol3/document.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/sbol3/document.py b/sbol3/document.py index f65a636..fc2795b 100644 --- a/sbol3/document.py +++ b/sbol3/document.py @@ -4,19 +4,27 @@ import logging import os import posixpath -import warnings -from pathlib import Path -from typing import Dict, Callable, List, Optional, Any, Union, Iterable - # import typing for typing.Sequence, which we don't want to confuse # with sbol3.Sequence import typing as pytyping +import warnings +from pathlib import Path +from typing import Any, Callable, Dict, Iterable, List, Optional, Union import pyshacl import rdflib -from . import * -from .object import BUILDER_REGISTER +from .constants import (JSONLD, NTRIPLES, OM_NS, PROV_NS, RDF_TYPE, RDF_XML, + SBOL3_NS, SBOL_IDENTIFIED, SBOL_LOGGER_NAME, + SBOL_NAMESPACE, SBOL_TOP_LEVEL, SORTED_NTRIPLES, + TURTLE) +from .custom import CustomIdentified, CustomTopLevel +from .error import SBOLError +from .identified import Identified +from .object import BUILDER_REGISTER, SBOLObject +from .property_base import SingletonProperty +from .toplevel import TopLevel +from .validation import ValidationReport _default_bindings = { 'sbol': SBOL3_NS, From 9496ef12dc28c9560506b1615466177cba062f46 Mon Sep 17 00:00:00 2001 From: GeneCodeSavvy Date: Fri, 28 Feb 2025 12:38:24 +0530 Subject: [PATCH 2/9] if else statement refactored --- sbol3/document.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/sbol3/document.py b/sbol3/document.py index fc2795b..27248fe 100644 --- a/sbol3/document.py +++ b/sbol3/document.py @@ -16,8 +16,7 @@ from .constants import (JSONLD, NTRIPLES, OM_NS, PROV_NS, RDF_TYPE, RDF_XML, SBOL3_NS, SBOL_IDENTIFIED, SBOL_LOGGER_NAME, - SBOL_NAMESPACE, SBOL_TOP_LEVEL, SORTED_NTRIPLES, - TURTLE) + SBOL_NAMESPACE, SBOL_TOP_LEVEL, SORTED_NTRIPLES) from .custom import CustomIdentified, CustomTopLevel from .error import SBOLError from .identified import Identified @@ -169,9 +168,9 @@ def _build_object(self, identity: str, types: List[str]) -> Optional[Identified] else: try: builder = self._uri_type_map[sbol_type] - except KeyError: + except KeyError as exc: logging.warning(f'No builder found for {sbol_type}') - raise SBOLError(f'Unknown type {sbol_type}') + raise SBOLError(f'Unknown type {sbol_type}') from exc result = builder(identity=identity, type_uri=sbol_type) # Fix https://github.com/SynBioDex/pySBOL3/issues/264 if isinstance(result, TopLevel): @@ -322,10 +321,9 @@ def file_extension(file_format: str) -> str: RDF_XML: '.xml', TURTLE: '.ttl' } - if file_format in types_with_standard_extension: - return types_with_standard_extension[file_format] - else: + if not file_format in types_with_standard_extension: raise ValueError('Provided file format is not a valid one.') + return types_with_standard_extension[file_format] # Formats: 'n3', 'nt', 'turtle', 'xml' def read(self, location: Union[Path, str], file_format: str = None) -> None: From 21bc719d0fd5ee8d9e81fb4825fd9392edeb572f Mon Sep 17 00:00:00 2001 From: GeneCodeSavvy Date: Fri, 28 Feb 2025 13:21:07 +0530 Subject: [PATCH 3/9] location.py --- sbol3/location.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/sbol3/location.py b/sbol3/location.py index d1769e1..929cd44 100644 --- a/sbol3/location.py +++ b/sbol3/location.py @@ -1,8 +1,17 @@ import abc -from typing import Union, Any, Optional - -from . import * +from typing import Any, Optional, Union + +from .constants import (PYSBOL3_MISSING, SBOL_CUT, SBOL_END, + SBOL_ENTIRE_SEQUENCE, SBOL_ORDER, SBOL_ORIENTATION, + SBOL_RANGE, SBOL_SEQUENCES, SBOL_START) +from .document import Document +from .identified import Identified +from .int_property import IntProperty +from .refobj_property import ReferencedObject +from .sequence import Sequence from .typing import uri_singleton +from .uri_property import URIProperty +from .validation import ValidationReport int_property = Union[IntProperty, int] From 36e885a0b5a686e9fc647ffcb89b21216acd1909 Mon Sep 17 00:00:00 2001 From: GeneCodeSavvy Date: Fri, 28 Feb 2025 13:31:20 +0530 Subject: [PATCH 4/9] cleanup --- sbol3/document.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sbol3/document.py b/sbol3/document.py index 27248fe..06e8065 100644 --- a/sbol3/document.py +++ b/sbol3/document.py @@ -16,7 +16,8 @@ from .constants import (JSONLD, NTRIPLES, OM_NS, PROV_NS, RDF_TYPE, RDF_XML, SBOL3_NS, SBOL_IDENTIFIED, SBOL_LOGGER_NAME, - SBOL_NAMESPACE, SBOL_TOP_LEVEL, SORTED_NTRIPLES) + SBOL_NAMESPACE, SBOL_TOP_LEVEL, SORTED_NTRIPLES, + TURTLE) from .custom import CustomIdentified, CustomTopLevel from .error import SBOLError from .identified import Identified From 7571ee2de2dc52561fd2cef7c3d38833c977bc94 Mon Sep 17 00:00:00 2001 From: GeneCodeSavvy Date: Fri, 28 Feb 2025 23:04:23 +0530 Subject: [PATCH 5/9] use dictionary literal --- sbol3/document.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbol3/document.py b/sbol3/document.py index 06e8065..892bece 100644 --- a/sbol3/document.py +++ b/sbol3/document.py @@ -206,7 +206,7 @@ def _parse_objects(self, graph: rdflib.Graph) -> Dict[str, SBOLObject]: def _parse_attributes(objects, graph) -> dict[str, Identified]: # Track the child objects that get assigned to optimize the # search for orphans later in the loading process. - child_objects = dict() + child_objects = {} for s, p, o in graph.triples((None, None, None)): str_s = str(s) str_p = str(p) From 91afffec9d8d3e5ee1f0a76a67a0a99dd04d6dfc Mon Sep 17 00:00:00 2001 From: GeneCodeSavvy Date: Fri, 28 Feb 2025 23:31:53 +0530 Subject: [PATCH 6/9] om_compound --- sbol3/om_compound.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sbol3/om_compound.py b/sbol3/om_compound.py index 85b57f3..8483c2b 100644 --- a/sbol3/om_compound.py +++ b/sbol3/om_compound.py @@ -1,9 +1,15 @@ import abc -from typing import Union, List, Any - -from . import * - +from typing import Any, List, Union + +from .constants import (OM_HAS_BASE, OM_HAS_DENOMINATOR, OM_HAS_EXPONENT, + OM_HAS_NUMERATOR, OM_HAS_TERM1, OM_HAS_TERM2, OM_LABEL, + OM_SYMBOL, OM_UNIT_DIVISION, OM_UNIT_EXPONENTIATION, + OM_UNIT_MULTIPLICATION, PYSBOL3_MISSING) +from .document import Document +from .int_property import IntProperty +from .object import SBOLObject from .om_unit import Unit +from .refobj_property import ReferencedObject class CompoundUnit(Unit, abc.ABC): From b23e041a4ac89f10139e16637ebf146d5b5636ca Mon Sep 17 00:00:00 2001 From: GeneCodeSavvy Date: Sat, 1 Mar 2025 00:14:04 +0530 Subject: [PATCH 7/9] solved : E713 test for membership should be 'not in' --- sbol3/document.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbol3/document.py b/sbol3/document.py index 892bece..826ca95 100644 --- a/sbol3/document.py +++ b/sbol3/document.py @@ -322,7 +322,7 @@ def file_extension(file_format: str) -> str: RDF_XML: '.xml', TURTLE: '.ttl' } - if not file_format in types_with_standard_extension: + if file_format not in types_with_standard_extension: raise ValueError('Provided file format is not a valid one.') return types_with_standard_extension[file_format] From 7e795021d9974a7b8696ddfc3af5905ca45db5d0 Mon Sep 17 00:00:00 2001 From: GeneCodeSavvy Date: Sat, 1 Mar 2025 00:54:56 +0530 Subject: [PATCH 8/9] toplevel.py --- sbol3/toplevel.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/sbol3/toplevel.py b/sbol3/toplevel.py index 7cca28d..c89d701 100644 --- a/sbol3/toplevel.py +++ b/sbol3/toplevel.py @@ -3,14 +3,21 @@ 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 . import * +from typing import Any, Callable, Dict, Optional + +from .config import get_namespace +from .constants import (PYSBOL3_DEFAULT_NAMESPACE, SBOL_HAS_ATTACHMENT, + SBOL_NAMESPACE) +from .identified import Identified +from .property_base import ListProperty +from .refobj_property import ReferencedObject from .typing import * +from .uri_property import URIProperty +from .validation import ValidationReport class TopLevel(Identified): From 9222b6d5250b505b6c9f3733e1cc727601960d8d Mon Sep 17 00:00:00 2001 From: GeneCodeSavvy Date: Sat, 1 Mar 2025 09:09:43 +0530 Subject: [PATCH 9/9] cleanup --- sbol3/toplevel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbol3/toplevel.py b/sbol3/toplevel.py index c89d701..f1072d8 100644 --- a/sbol3/toplevel.py +++ b/sbol3/toplevel.py @@ -15,7 +15,7 @@ from .identified import Identified from .property_base import ListProperty from .refobj_property import ReferencedObject -from .typing import * +from .typing import Property, Union, ownedobj_list_arg, refobj_list_arg from .uri_property import URIProperty from .validation import ValidationReport