Skip to content

Commit 79e952a

Browse files
authored
Merge branch 'main' into consider-using-get
2 parents e076ba6 + 8bfdfa9 commit 79e952a

File tree

8 files changed

+27
-30
lines changed

8 files changed

+27
-30
lines changed

sbol3/document.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
import logging
55
import os
66
import posixpath
7-
import warnings
8-
from pathlib import Path
9-
from typing import Dict, Callable, List, Optional, Any, Union, Iterable
10-
117
# import typing for typing.Sequence, which we don't want to confuse
128
# with sbol3.Sequence
139
import typing as pytyping
10+
import warnings
11+
from pathlib import Path
12+
from typing import Any, Callable, Dict, Iterable, List, Optional, Union
1413

1514
import pyshacl
1615
import rdflib
@@ -124,7 +123,7 @@ def _build_extension_object(self, identity: str, sbol_type: str,
124123
build_type = type_uri
125124
break
126125
except KeyError:
127-
logging.warning(f'No builder found for {type_uri}')
126+
logging.warning('No builder for %s', type_uri)
128127
if builder is None:
129128
builder = custom_types[sbol_type]
130129
build_type = types[0]
@@ -162,7 +161,7 @@ def _build_object(self, identity: str, types: List[str]) -> Optional[Identified]
162161
try:
163162
builder = self._uri_type_map[sbol_type]
164163
except KeyError:
165-
logging.warning(f'No builder found for {sbol_type}')
164+
logging.warning('No builder found for %s', sbol_type)
166165
raise SBOLError(f'Unknown type {sbol_type}')
167166
result = builder(identity=identity, type_uri=sbol_type)
168167
# Fix https://github.com/SynBioDex/pySBOL3/issues/264

sbol3/object.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import uuid
44
import warnings
55
from collections import defaultdict
6+
from typing import Callable, Dict, Optional, Union
67
from urllib.parse import urlparse
7-
from typing import Dict, Callable, Optional, Union
88

99
from . import *
1010

@@ -115,7 +115,7 @@ def copy(self, target_doc=None, target_namespace=None):
115115
try:
116116
builder = BUILDER_REGISTER[self.type_uri]
117117
except KeyError:
118-
logging.warning(f'No builder found for {self.type_uri}; assuming {self.__class__.__name__}')
118+
logging.warning('No builder found for %s; assuming %s', self.type_uri, self.__class__.__name__)
119119
builder = self.__class__
120120
new_obj = builder(**dict(identity=new_uri, type_uri=self.type_uri))
121121

sbol3/toplevel.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
import copy
44
import math
55
import posixpath
6+
import typing
67
import urllib.parse
78
import uuid
89
import warnings
9-
from typing import Dict, Callable, Optional, Any
10-
import typing
10+
from typing import Any, Callable, Dict, Optional
1111

1212
from . import *
1313
from .typing import *
@@ -234,8 +234,8 @@ def update_references_traverser(x):
234234
if v.property_uri not in x._properties:
235235
continue
236236
items = x._properties[v.property_uri]
237-
for i in range(len(items)):
238-
str_item = str(items[i])
237+
for i, item in enumerate(items):
238+
str_item = str(item)
239239
if str_item in identity_map:
240240
new_reference = identity_map[str_item].identity
241241
# The item is probably an rdflib.URIRef. We take

setup.cfg

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,8 @@ max-line-length = 119
1414
disable = abstract-class-instantiated,
1515
attribute-defined-outside-init,
1616
catching-non-exception,
17-
consider-using-generator,
1817
disallowed-name,
19-
implicit-str-concat,
2018
import-outside-toplevel,
21-
logging-not-lazy,
22-
consider-using-enumerate,
2319
consider-using-f-string,
2420
cyclic-import,
2521
duplicate-code,
@@ -29,7 +25,6 @@ disable = abstract-class-instantiated,
2925
inconsistent-return-statements,
3026
invalid-name,
3127
isinstance-second-argument-not-valid-type,
32-
logging-fstring-interpolation,
3328
missing-class-docstring,
3429
missing-function-docstring,
3530
missing-module-docstring,

test/test_component.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,7 @@ def test_cloning_references(self):
148148
doc2 = sbol3.Document()
149149
doc2.add(toggle_clone)
150150
self.assertEqual(len(toggle.constraints), len(toggle_clone.constraints))
151-
for i in range(len(toggle.constraints)):
152-
c = toggle.constraints[i]
151+
for i, c in enumerate(toggle.constraints):
153152
c_clone = toggle_clone.constraints[i]
154153
self.assertNotEqual(c.identity, c_clone.identity)
155154
s = c.subject.lookup()

test/test_document.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,15 @@ def test_add_iterable(self):
125125
sbol3.set_namespace('https://github.com/synbiodex/pysbol3')
126126
doc = sbol3.Document()
127127
objects = [sbol3.Component(name, types=[sbol3.SBO_DNA])
128-
for name in ['foo', 'bar', 'baz' 'quux']]
128+
for name in ['foo', 'bar', 'baz', 'quux']]
129129
result = doc.add(objects)
130130
self.assertEqual(len(objects), len(result))
131131
self.assertListEqual(objects, result)
132132
#
133133
# Test adding a non-TopLevel in a list
134134
doc = sbol3.Document()
135135
objects = [sbol3.Component(name, types=[sbol3.SBO_DNA])
136-
for name in ['foo', 'bar', 'baz' 'quux']]
136+
for name in ['foo', 'bar', 'baz', 'quux']]
137137
objects.insert(2, 'non-TopLevel')
138138
with self.assertRaises(TypeError):
139139
doc.add(objects)
@@ -736,14 +736,14 @@ def test_ntriples_blank_line(self):
736736
doc.add(c1)
737737
output = doc.write_string(file_format=sbol3.NTRIPLES)
738738
lines = output.splitlines()
739-
num_blanks = sum([1 for line in lines if not line])
739+
num_blanks = sum(1 for line in lines if not line)
740740
# Expecting no blank lines
741741
self.assertEqual(0, num_blanks)
742742

743743
# Now test sorted n-triples
744744
sorted_output = doc.write_string(file_format=sbol3.SORTED_NTRIPLES)
745745
sorted_lines = sorted_output.splitlines()
746-
num_blanks = sum([1 for line in sorted_lines if not line])
746+
num_blanks = sum(1 for line in sorted_lines if not line)
747747
# Expecting no blank lines
748748
self.assertEqual(0, num_blanks)
749749

test/test_examples.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import logging
22
import os
3+
import shutil
34
import subprocess
45
import sys
5-
import unittest
66
import tempfile
7-
import shutil
7+
import unittest
8+
89
import rdflib
910
import rdflib.compare
1011

@@ -48,8 +49,8 @@ def test_circuit_example(self):
4849
expected_iso = rdflib.compare.to_isomorphic(expected_graph)
4950
rdf_diff = rdflib.compare.graph_diff(expected_iso, actual_iso)
5051
if rdf_diff[1] or rdf_diff[2]:
51-
self.logger.warning('Detected %d different RDF triples in %s' %
52-
(len(rdf_diff[1]) + len(rdf_diff[2]), out_path))
52+
self.logger.warning('Detected %d different RDF triples in %s',
53+
len(rdf_diff[1]) + len(rdf_diff[2]), out_path)
5354
for stmt in rdf_diff[1]:
5455
self.logger.warning('Only in expected: %r', stmt)
5556
for stmt in rdf_diff[2]:

test/test_roundtrip.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,11 @@ def run_round_trip_file(self, test_path, file_format):
147147
iso2 = rdflib.compare.to_isomorphic(g2)
148148
rdf_diff = rdflib.compare.graph_diff(iso1, iso2)
149149
if rdf_diff[1] or rdf_diff[2]:
150-
self.logger.warning('Detected %d different RDF triples in %s' %
151-
(len(rdf_diff[1]) + len(rdf_diff[2]), test_path))
150+
self.logger.warning(
151+
'Detected %d different RDF triples in %s',
152+
len(rdf_diff[1]) + len(rdf_diff[2]), test_path
153+
)
154+
152155
if not self.logger.isEnabledFor(logging.DEBUG):
153156
self.logger.warning('Set environment variable %s to see details',
154157
DEBUG_ENV_VAR)
@@ -165,7 +168,7 @@ def test_sbol3_files(self):
165168
for test_file in self.find_all_files(test_dir):
166169
basename = os.path.basename(test_file)
167170
if os.path.splitext(basename)[0] in skip_list:
168-
self.logger.debug(f'Skipping {test_file}')
171+
self.logger.debug('Skipping %s', test_file)
169172
continue
170173
file_format = self.rdf_type(test_file)
171174
if not file_format:

0 commit comments

Comments
 (0)