Skip to content

Commit 51761b3

Browse files
committed
add pyupgrade pre-commit hook and rerun on all files
1 parent 2311d55 commit 51761b3

File tree

5 files changed

+16
-14
lines changed

5 files changed

+16
-14
lines changed

.pre-commit-config.yaml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ repos:
22
- repo: https://github.com/myint/autoflake
33
rev: v1.4
44
hooks:
5-
- id: autoflake
6-
args: [--in-place, --remove-all-unused-imports, --remove-unused-variable, --ignore-init-module-imports]
5+
- id: autoflake
6+
args: [--in-place, --remove-all-unused-imports, --remove-unused-variable, --ignore-init-module-imports]
77

88
- repo: https://github.com/psf/black
99
rev: 21.11b1
1010
hooks:
11-
- id: black
11+
- id: black
1212

1313
- repo: https://github.com/pycqa/flake8
1414
rev: 4.0.1
@@ -22,3 +22,9 @@ repos:
2222
- id: check-yaml
2323
- id: end-of-file-fixer
2424
- id: trailing-whitespace
25+
26+
- repo: https://github.com/asottile/pyupgrade
27+
rev: v2.31.0
28+
hooks:
29+
- id: pyupgrade
30+
args: [--py37-plus]

atomate/vasp/analysis/linear_response.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def procure_response_dict(
4646
# Obtain occupancy values
4747
n_tot = float(outcar_dict["charge"][i][orbital])
4848
# FIXME: Adapt for noncollinear
49-
m_z = float((outcar_dict["magnetization"][i][orbital]))
49+
m_z = float(outcar_dict["magnetization"][i][orbital])
5050
n_up = 0.5 * (n_tot + m_z)
5151
n_dn = 0.5 * (n_tot - m_z)
5252

atomate/vasp/workflows/base/hubbard_hund_linresp.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,4 @@ def __init__(
792792
t.append(RunVaspCustodian(vasp_cmd=vasp_cmd, auto_npar=">>auto_npar<<"))
793793
t.append(PassCalcLocs(name=name))
794794
t.append(VaspToDb(db_file=db_file, **vasptodb_kwargs))
795-
super(HubbardHundLinRespFW, self).__init__(
796-
t, parents=parents, name=fw_name, **kwargs
797-
)
795+
super().__init__(t, parents=parents, name=fw_name, **kwargs)

atomate/vasp/workflows/tests/test_hubbard_hund_linresp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def test_analysis(self):
2525
formula_pretty = "LiNiPO4"
2626
tasks = self.get_task_collection()
2727
with open(
28-
os.path.join(ref_dir, "sample_tasks_multisite_spinpolarized.json"), "r"
28+
os.path.join(ref_dir, "sample_tasks_multisite_spinpolarized.json")
2929
) as f:
3030
sample_tasks = load(f)
3131
wf_uuid = sample_tasks[0]["wf_meta"]["wf_uuid"]

scripts/atwf

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#!/usr/bin/env python
22
# Copyright (c) atomate Development Team.
33

4-
from __future__ import division, print_function, unicode_literals
5-
64
import argparse
75
import ast
86
import os
@@ -63,7 +61,7 @@ def _get_wf(args, structure):
6361
presets_dir, "..", "base", "library", spec_path
6462
)
6563
else:
66-
raise ValueError("Unknown library: {}".format(args.library))
64+
raise ValueError(f"Unknown library: {args.library}")
6765
d = loadfn(spec_path)
6866
return get_wf_from_spec_dict(structure, d, args.common_param_updates)
6967

@@ -130,7 +128,7 @@ def submit_test_suite(args):
130128
wfs.append(wf_func(*custom_args[name]))
131129
else:
132130
wfs.append(wf_func(structs[0]))
133-
wfs = [add_tags(wf, "test set {}".format(dt)) for wf in wfs]
131+
wfs = [add_tags(wf, f"test set {dt}") for wf in wfs]
134132
for wf in wfs:
135133
add_to_lpad(wf, write_namefile=False)
136134

@@ -145,11 +143,11 @@ def verify_test_suite(args):
145143
]
146144
rep_dict = {k["_id"]: k["count"] for k in lpad.fireworks.aggregate(pipeline)}
147145
dt = "".join(tag.split()[2:])
148-
print("Test set submitted at {}".format(dt))
146+
print(f"Test set submitted at {dt}")
149147
if args.report:
150148
print(" Test fw state summary:")
151149
for state, count in rep_dict.items():
152-
print(" -{}: {}".format(state, count))
150+
print(f" -{state}: {count}")
153151
count = sum(rep_dict.values())
154152
if rep_dict.get("COMPLETED", None) == count:
155153
print(" All test workflows successfully completed")

0 commit comments

Comments
 (0)