diff --git a/sbol3/document.py b/sbol3/document.py index f65a636..8da1785 100644 --- a/sbol3/document.py +++ b/sbol3/document.py @@ -4,13 +4,12 @@ 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 @@ -124,7 +123,7 @@ def _build_extension_object(self, identity: str, sbol_type: str, build_type = type_uri break except KeyError: - logging.warning(f'No builder found for {type_uri}') + logging.warning('No builder for %s', type_uri) if builder is None: builder = custom_types[sbol_type] build_type = types[0] @@ -162,7 +161,7 @@ def _build_object(self, identity: str, types: List[str]) -> Optional[Identified] try: builder = self._uri_type_map[sbol_type] except KeyError: - logging.warning(f'No builder found for {sbol_type}') + logging.warning('No builder found for %s', sbol_type) raise SBOLError(f'Unknown type {sbol_type}') result = builder(identity=identity, type_uri=sbol_type) # Fix https://github.com/SynBioDex/pySBOL3/issues/264 diff --git a/sbol3/object.py b/sbol3/object.py index 1d00961..7114ca7 100644 --- a/sbol3/object.py +++ b/sbol3/object.py @@ -3,8 +3,8 @@ import uuid import warnings from collections import defaultdict +from typing import Callable, Dict, Optional, Union from urllib.parse import urlparse -from typing import Dict, Callable, Optional, Union from . import * @@ -115,7 +115,7 @@ def copy(self, target_doc=None, target_namespace=None): try: builder = BUILDER_REGISTER[self.type_uri] except KeyError: - logging.warning(f'No builder found for {self.type_uri}; assuming {self.__class__.__name__}') + logging.warning('No builder found for %s; assuming %s', self.type_uri, self.__class__.__name__) builder = self.__class__ new_obj = builder(**dict(identity=new_uri, type_uri=self.type_uri)) diff --git a/setup.cfg b/setup.cfg index be0b274..f328f2d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -19,7 +19,6 @@ disable = abstract-class-instantiated, disallowed-name, implicit-str-concat, import-outside-toplevel, - logging-not-lazy, consider-using-f-string, cyclic-import, duplicate-code, @@ -29,7 +28,6 @@ disable = abstract-class-instantiated, inconsistent-return-statements, invalid-name, isinstance-second-argument-not-valid-type, - logging-fstring-interpolation, missing-class-docstring, missing-function-docstring, missing-module-docstring, diff --git a/test/test_examples.py b/test/test_examples.py index 7686477..e3b0c1b 100644 --- a/test/test_examples.py +++ b/test/test_examples.py @@ -1,10 +1,11 @@ import logging import os +import shutil import subprocess import sys -import unittest import tempfile -import shutil +import unittest + import rdflib import rdflib.compare @@ -48,8 +49,8 @@ def test_circuit_example(self): expected_iso = rdflib.compare.to_isomorphic(expected_graph) rdf_diff = rdflib.compare.graph_diff(expected_iso, actual_iso) if rdf_diff[1] or rdf_diff[2]: - self.logger.warning('Detected %d different RDF triples in %s' % - (len(rdf_diff[1]) + len(rdf_diff[2]), out_path)) + self.logger.warning('Detected %d different RDF triples in %s', + len(rdf_diff[1]) + len(rdf_diff[2]), out_path) for stmt in rdf_diff[1]: self.logger.warning('Only in expected: %r', stmt) for stmt in rdf_diff[2]: diff --git a/test/test_roundtrip.py b/test/test_roundtrip.py index 4810262..5546451 100644 --- a/test/test_roundtrip.py +++ b/test/test_roundtrip.py @@ -147,8 +147,11 @@ def run_round_trip_file(self, test_path, file_format): iso2 = rdflib.compare.to_isomorphic(g2) rdf_diff = rdflib.compare.graph_diff(iso1, iso2) if rdf_diff[1] or rdf_diff[2]: - self.logger.warning('Detected %d different RDF triples in %s' % - (len(rdf_diff[1]) + len(rdf_diff[2]), test_path)) + self.logger.warning( + 'Detected %d different RDF triples in %s', + len(rdf_diff[1]) + len(rdf_diff[2]), test_path + ) + if not self.logger.isEnabledFor(logging.DEBUG): self.logger.warning('Set environment variable %s to see details', DEBUG_ENV_VAR) @@ -165,7 +168,7 @@ def test_sbol3_files(self): for test_file in self.find_all_files(test_dir): basename = os.path.basename(test_file) if os.path.splitext(basename)[0] in skip_list: - self.logger.debug(f'Skipping {test_file}') + self.logger.debug('Skipping %s', test_file) continue file_format = self.rdf_type(test_file) if not file_format: