Skip to content

Commit 24f5811

Browse files
Merge branch 'main' into unnecessary-pass
2 parents dcfbae3 + 34fcc5e commit 24f5811

9 files changed

Lines changed: 19 additions & 20 deletions

File tree

sbol3/document.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def _parse_objects(self, graph: rdflib.Graph) -> Dict[str, SBOLObject]:
180180
# 6.11 of the spec) and we instantiate it specially.
181181
#
182182
identity_types: Dict[str, List[str]] = collections.defaultdict(list)
183-
for s, p, o in graph.triples((None, rdflib.RDF.type, None)):
183+
for s, _, o in graph.triples((None, rdflib.RDF.type, None)):
184184
str_o = str(o)
185185
str_s = str(s)
186186
identity_types[str_s].append(str_o)
@@ -238,7 +238,7 @@ def _clean_up_singletons(objects: Dict[str, SBOLObject]):
238238
# in multiple values in a singleton property. Only the first value
239239
# is used, so the value read from file is ignored.
240240
for _, obj in objects.items():
241-
for name, attr in obj.__dict__.items():
241+
for _, attr in obj.__dict__.items():
242242
if isinstance(attr, SingletonProperty):
243243
prop_uri = attr.property_uri
244244
store = attr._storage()
@@ -472,7 +472,7 @@ def write(self, fpath: Union[Path, str], file_format: str = None) -> None:
472472
file_format = self._guess_format(_fpath)
473473
if file_format is None:
474474
raise ValueError('Unable to determine file format')
475-
with open(_fpath, 'w') as outfile:
475+
with open(_fpath, 'w', encoding='utf-8') as outfile:
476476
outfile.write(self.write_string(file_format))
477477

478478
def graph(self) -> rdflib.Graph:

sbol3/object.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,19 @@ def _make_identity(name: str) -> Union[str, None]:
5555
"""
5656
if name is None:
5757
return None
58-
name_is_url = SBOLObject._is_url(name)
59-
if name_is_url:
58+
59+
# Case 1: The name is already a valid URL
60+
if SBOLObject._is_url(name):
6061
return name.strip(posixpath.sep)
62+
63+
# Case 2: The name is a valid UUID
6164
try:
62-
# If it is a UUID, accept it as the identity
63-
identity_uuid = uuid.UUID(name)
65+
uuid.UUID(name)
6466
return name
6567
except ValueError:
6668
pass
67-
# Not a URL or a UUID, so append to the namespace
69+
70+
# Case 3: The name is neither a URL or a UUID, so append to the namespace
6871
base_uri = get_namespace()
6972
if base_uri is None:
7073
# See https://github.com/SynBioDex/pySBOL3/issues/254

sbol3/toplevel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def update_references_traverser(x):
228228
# Use the identity map to update references.
229229
# References to objects outside of the object
230230
# being cloned will be left as is.
231-
for k, v in x.__dict__.items():
231+
for _, v in x.__dict__.items():
232232
if not isinstance(v, Property):
233233
continue
234234
if v.property_uri not in x._properties:

setup.cfg

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,8 @@ disable = abstract-class-instantiated,
3838
too-many-positional-arguments,
3939
too-many-public-methods,
4040
undefined-variable,
41-
unspecified-encoding,
4241
unused-argument,
4342
unused-import,
44-
unused-variable,
4543
unused-wildcard-import,
4644
useless-parent-delegation,
4745
useless-return,

test/test_custom.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import sbol3
1010

11-
1211
PYSBOL3_CUSTOM_TOP = 'https://github.com/synbiodex/pysbol3#customTop'
1312
PYSBOL3_CUSTOM_UNREGISTERED_TOP = 'https://github.com/synbiodex/pysbol3#customUnregisteredTop'
1413
PYSBOL3_CUSTOM_BOOL = 'https://github.com/synbiodex/pysbol3#customBool'
@@ -136,11 +135,11 @@ def test_none_identity(self):
136135
# as a CustomTopLevel identity. And also if identity
137136
# is an empty string or not a string.
138137
with self.assertRaises(ValueError):
139-
obj = CustomTopClass(None)
138+
_ = CustomTopClass(None)
140139
with self.assertRaises(ValueError):
141-
obj = CustomTopClass('')
140+
_ = CustomTopClass('')
142141
with self.assertRaises(ValueError):
143-
obj = CustomTopClass(3)
142+
_ = CustomTopClass(3)
144143

145144

146145
class TestCustomIdentified(unittest.TestCase):

test/test_document.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def test_file_extension(self):
5252
self.assertEqual(extension_2, '.xml')
5353
# 3. for invalid file formats, valueError must be raised
5454
with self.assertRaises(ValueError):
55-
extension_3 = sbol3.Document.file_extension(file_format_3)
55+
_ = sbol3.Document.file_extension(file_format_3)
5656

5757
def test_read_ntriples(self):
5858
# Initial test of Document.read
@@ -218,7 +218,7 @@ def test_write_string(self):
218218
with tempfile.TemporaryDirectory() as tmpdirname:
219219
test_file = os.path.join(tmpdirname, filename)
220220
doc.write(test_file, sbol3.SORTED_NTRIPLES)
221-
with open(test_file, 'r') as infile:
221+
with open(test_file, 'r', encoding='utf-8') as infile:
222222
expected = infile.read()
223223
actual = doc.write_string(sbol3.SORTED_NTRIPLES)
224224
self.assertEqual(expected, actual)

test/test_object.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ def test_replace_namespace(self):
6262
def test_copy_is_deprecated(self):
6363
namespace = 'https://github.com/synbiodex/pysbol3'
6464
sbol3.set_namespace(namespace)
65-
name = 'ed1'
6665
ed1 = sbol3.ExternallyDefined(types=[sbol3.SBO_DNA],
6766
definition='https://example.org/other')
6867
with self.assertWarns(DeprecationWarning):

test/test_subcomponent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def test_list_wrapping(self):
5656
instance_uri = 'https://example.org/instance'
5757
seq1 = sbol3.Sequence('seq1')
5858
test_loc = sbol3.EntireSequence(seq1)
59-
seq2 = sbol3.Sequence('seq2')
59+
_ = sbol3.Sequence('seq2')
6060
test_source_loc = sbol3.EntireSequence(seq1)
6161
subcomp1 = sbol3.SubComponent(instance_of=instance_uri,
6262
locations=test_loc,

test/test_varcomp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def test_list_wrapping(self):
7878
# See https://github.com/SynBioDex/pySBOL3/issues/301
7979
sbol3.set_namespace('https://github.com/synbiodex/pysbol3')
8080
seq = sbol3.Sequence('seq1')
81-
test_loc = sbol3.EntireSequence(seq)
81+
_ = sbol3.EntireSequence(seq)
8282
variable_uri = 'https://example.org/variable'
8383
var_coll_uri = 'https://example.org/collection'
8484
var_feat1 = sbol3.VariableFeature(cardinality=sbol3.SBOL_ZERO_OR_MORE,

0 commit comments

Comments
 (0)