Skip to content

Commit

Permalink
Merge pull request #396 from grahamgower/lint
Browse files Browse the repository at this point in the history
Fix some f-strings; additional linting.
  • Loading branch information
grahamgower committed Dec 6, 2021
2 parents dbb10b7 + e87f887 commit f09b2cb
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
8 changes: 4 additions & 4 deletions demes/demes.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def nonzero_len(self, attribute, value):
def valid_deme_name(self, attribute, value):
if not value.isidentifier():
raise ValueError(
"Invalid deme name `{self.name}`. Names must be valid python identifiers. "
f"Invalid deme name '{value}'. Names must be valid python identifiers. "
"We recommend choosing a name that starts with a letter or "
"underscore, and is followed by one or more letters, numbers, "
"or underscores."
Expand Down Expand Up @@ -1996,7 +1996,7 @@ def fromdict(cls, data: MutableMapping[str, Any]) -> "Graph":
pop_list(data, "demes", required_type=MutableMapping, scope="toplevel")
):
if "name" not in deme_data:
raise KeyError("demes[{i}]: required field 'name' not found")
raise KeyError(f"demes[{i}]: required field 'name' not found")
deme_name = deme_data.pop("name")
check_allowed(
deme_data, allowed_fields_deme_inner, f"demes[{i}] {deme_name}"
Expand Down Expand Up @@ -2179,7 +2179,7 @@ def simplify_epochs(data):
if implied by the deme ancestor(s)'s end time(s).
"""
for deme in data["demes"]:
for j, epoch in enumerate(deme["epochs"]):
for epoch in deme["epochs"]:
if epoch["size_function"] in ("constant", "exponential"):
del epoch["size_function"]
if epoch["start_size"] == epoch["end_size"]:
Expand Down Expand Up @@ -2276,7 +2276,7 @@ def collapse_demes(pairs):
asymmetric.remove(mig)
pairs.remove(deme_pair)
# add to symmetric list
sym_mig = dict(demes=[d for d in deme_set], rate=k[0])
sym_mig = dict(demes=list(deme_set), rate=k[0])
if k[1] is not None:
sym_mig["start_time"] = k[1]
if k[2] is not None:
Expand Down
2 changes: 1 addition & 1 deletion demes/ms.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ValueErrorArgumentParser(argparse.ArgumentParser):
"""

def error(self, message):
_, exc, traceback = sys.exc_info()
_, exc, _ = sys.exc_info()
raise ValueError(str(exc))


Expand Down
20 changes: 20 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,23 @@ target_version = py36
[tool:pytest]
addopts = -n auto
testpaths = tests

[pylint.messages_control]
disable =
chained-comparison,
fixme,
invalid-name,
missing-docstring,
missing-module-docstring,
superfluous-parens,
protected-access,
too-few-public-methods,
too-many-arguments,
too-many-branches,
too-many-instance-attributes,
too-many-lines,
too-many-locals,
too-many-nested-blocks,
too-many-statements,
unspecified-encoding,
unused-argument,
4 changes: 2 additions & 2 deletions tests/test_ms.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def check(command, num_demes: int, migration: bool, N0=1):
demes.from_ms(cmd, N0=1)

for bad_sample_configuration in ("50 0 0 2", "2 0 0 0 0 0 2"):
cmd = "ms 2 1 -t 1.0 -I {bad_sample_configuration}"
cmd = f"ms 2 1 -t 1.0 -I {bad_sample_configuration}"
with pytest.raises(ValueError):
demes.from_ms(cmd, N0=1)

Expand Down Expand Up @@ -1496,7 +1496,7 @@ def test_li_and_durbin(self):
N0=N_ref(theta=104693, mu=mu, length=30000000),
)

def schiffels_inferring_human_population_size(self):
def test_schiffels_inferring_human_population_size(self):
# Schiffels & Durbin (2014), https://doi.org/10.1038/ng.3015
mu = 1.25e-8
# Split simulation
Expand Down

0 comments on commit f09b2cb

Please sign in to comment.