Skip to content

Commit 73b5761

Browse files
committed
More flake highlighted code tweaks
1 parent 1a048fc commit 73b5761

File tree

6 files changed

+22
-24
lines changed

6 files changed

+22
-24
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,4 @@ cython_debug/
164164
/examples/document.specification.bson
165165
/examples/neuroml2/hello_world.v.dat
166166
/examples/sbml/example_sbml_test.xml
167+
/updatelibs.sh

docs/contributors.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import requests
22
import pandas as pd
3-
import json
43
import textwrap
54
from datetime import date
65

examples/sbml/sbml_validators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020

2121
def valid_kind(instance, attribute, value):
22-
if not value in sbml_si_units:
22+
if value not in sbml_si_units:
2323
raise ValueError(
2424
f"kind {value} must be one of the standard SI units: {sbml_si_units}"
2525
)

examples/sbml/test_sbml3.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import json
99
import yaml
10-
import os
1110

1211
from sbml32spec import *
1312

src/modelspec/base_types.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,6 @@ def from_yaml(cls, yaml_str: str) -> "Base":
165165
"""Instantiate an modelspec object from a YAML string"""
166166
return cls.from_dict(yaml.load(yaml_str, Loader=yaml.SafeLoader))
167167

168-
@classmethod
169-
def from_yaml_file(cls, yaml_file: str) -> "Base":
170-
"""Instantiate an modelspec object from a file containing YAML"""
171-
return cls.from_dict(yaml.load(yaml_file, Loader=yaml.SafeLoader))
172-
173168
@classmethod
174169
def from_json(cls, json_str: str) -> "Base":
175170
"""Instantiate an modelspec object from a JSON string"""

src/modelspec/utils.py

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -269,14 +269,14 @@ def build_xml_element(data, parent=None):
269269
)
270270
if attribute_value is not None:
271271
if (
272-
type(attribute_value) is int
273-
or type(attribute_value) is float
274-
or type(attribute_value) is str
275-
or type(attribute_value) is bool
276-
or type(attribute_value) is list
272+
isinstance(attribute_value, int)
273+
or isinstance(attribute_value, float)
274+
or isinstance(attribute_value, str)
275+
or isinstance(attribute_value, bool)
276+
or isinstance(attribute_value, list)
277277
):
278278
parent.set(attribute_name, str(attribute_value))
279-
elif type(attribute_value) == dict:
279+
elif isinstance(attribute_value, dict):
280280
"""for k, v in attribute_value.items():
281281
child_element = build_xml_element(v)"""
282282
else:
@@ -327,7 +327,7 @@ def _parse_attributes(dict_format, to_build):
327327
)
328328

329329
if new_format:
330-
if type(to_build) == dict:
330+
if isinstance(to_build, dict):
331331
to_build[key] = value
332332

333333
elif key in to_build.allowed_children:
@@ -339,11 +339,11 @@ def _parse_attributes(dict_format, to_build):
339339
exec("to_build.%s.append(ff)" % key)
340340
else:
341341
if (
342-
type(value) == str
343-
or type(value) == int
344-
or type(value) == float
345-
or type(value) == bool
346-
or type(value) == list
342+
isinstance(value, str)
343+
or isinstance(value, int)
344+
or isinstance(value, float)
345+
or isinstance(value, bool)
346+
or isinstance(value, list)
347347
or value is None
348348
):
349349
to_build.__setattr__(key, value)
@@ -364,11 +364,15 @@ def _parse_attributes(dict_format, to_build):
364364
exec("to_build.%s = ff" % key)
365365

366366
else:
367-
if type(to_build) == dict:
367+
if isinstance(to_build, dict):
368368
to_build[key] = value
369-
elif type(value) == str or type(value) == int or type(value) == float:
369+
elif (
370+
isinstance(value, str)
371+
or isinstance(value, int)
372+
or isinstance(value, float)
373+
):
370374
to_build.__setattr__(key, value)
371-
elif type(value) == list:
375+
elif isinstance(value, list):
372376
type_to_use = to_build.allowed_children[key][1]
373377

374378
for vl in value:
@@ -397,7 +401,7 @@ def locate_file(f, base_dir):
397401

398402

399403
def _val_info(param_val):
400-
if type(param_val) == np.ndarray:
404+
if isinstance(param_val, np.ndarray):
401405
pp = "%s" % (np.array2string(param_val, threshold=4, edgeitems=1))
402406
pp = pp.replace("\n", "")
403407
pp += f" (NP {param_val.shape} {param_val.dtype})"

0 commit comments

Comments
 (0)