Skip to content

Commit 2e060a3

Browse files
pre-commit autoupdate (#4450)
* pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.11.12 → v0.12.2](astral-sh/ruff-pre-commit@v0.11.12...v0.12.2) - [github.com/pre-commit/mirrors-mypy: v1.16.0 → v1.16.1](pre-commit/mirrors-mypy@v1.16.0...v1.16.1) - [github.com/MarcoGorelli/cython-lint: v0.16.6 → v0.16.7](MarcoGorelli/cython-lint@v0.16.6...v0.16.7) - [github.com/RobertCraigie/pyright-python: v1.1.401 → v1.1.402](RobertCraigie/pyright-python@v1.1.401...v1.1.402) * pre-commit auto-fixes --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 5965e32 commit 2e060a3

File tree

13 files changed

+31
-44
lines changed

13 files changed

+31
-44
lines changed

.pre-commit-config.yaml

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

99
repos:
1010
- repo: https://github.com/astral-sh/ruff-pre-commit
11-
rev: v0.11.12
11+
rev: v0.12.2
1212
hooks:
1313
- id: ruff
1414
args: [--fix, --unsafe-fixes]
@@ -22,7 +22,7 @@ repos:
2222
- id: trailing-whitespace
2323

2424
- repo: https://github.com/pre-commit/mirrors-mypy
25-
rev: v1.16.0
25+
rev: v1.16.1
2626
hooks:
2727
- id: mypy
2828
additional_dependencies: [numpy>=1.2.5]
@@ -37,7 +37,7 @@ repos:
3737
exclude: src/pymatgen/analysis/aflow_prototypes.json
3838

3939
- repo: https://github.com/MarcoGorelli/cython-lint
40-
rev: v0.16.6
40+
rev: v0.16.7
4141
hooks:
4242
- id: cython-lint
4343
args: [--no-pycodestyle]
@@ -66,6 +66,6 @@ repos:
6666
args: [--drop-empty-cells, --keep-output]
6767

6868
- repo: https://github.com/RobertCraigie/pyright-python
69-
rev: v1.1.401
69+
rev: v1.1.402
7070
hooks:
7171
- id: pyright

src/pymatgen/analysis/transition_state.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -347,11 +347,11 @@ def combine_neb_plots(neb_analyses, arranged_neb_analyses=False, reverse_plot=Fa
347347
)
348348

349349
if arranged_neb_analyses:
350-
neb1_energies = (
351-
neb1_energies[0 : len(neb1_energies) - 1]
352-
+ [(neb1_energies[-1] + neb2_energies[0]) / 2]
353-
+ neb2_energies[1:]
354-
)
350+
neb1_energies = [
351+
*neb1_energies[0 : len(neb1_energies) - 1],
352+
(neb1_energies[-1] + neb2_energies[0]) / 2,
353+
*neb2_energies[1:],
354+
]
355355
neb1_structures += neb2.structures[1:]
356356
neb1_forces = list(neb1_forces) + list(neb2.forces)[1:]
357357
neb1_r = list(neb1_r) + [i + neb1_r[-1] for i in list(neb2.r)[1:]]

src/pymatgen/core/interface.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2816,7 +2816,7 @@ def from_slabs(
28162816
min_height = np.abs(film_max_c - film_min_c) + np.abs(sub_max_c - sub_min_c)
28172817

28182818
# Construct new lattice
2819-
abc = substrate_slab.lattice.abc[:2] + (min_height + gap + vacuum_over_film,)
2819+
abc = (*substrate_slab.lattice.abc[:2], min_height + gap + vacuum_over_film)
28202820
angles = substrate_slab.lattice.angles
28212821
lattice = Lattice.from_parameters(*abc, *angles)
28222822

src/pymatgen/core/operations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def operate_multi(self, points: ArrayLike) -> NDArray[np.float64]:
139139
Numpy array of coordinates after operation
140140
"""
141141
points = np.asarray(points)
142-
affine_points = np.concatenate([points, np.ones(points.shape[:-1] + (1,))], axis=-1)
142+
affine_points = np.concatenate([points, np.ones((*points.shape[:-1], 1))], axis=-1)
143143
return np.inner(affine_points, self.affine_matrix)[..., :-1]
144144

145145
def apply_rotation_only(self, vector: NDArray) -> NDArray:

src/pymatgen/electronic_structure/boltztrap.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,7 @@ def write_energy(self, output_file) -> None:
273273
)
274274
a, b, c = kpt.frac_coords
275275
file.write(f"{a:12.8f} {b:12.8f} {c:12.8f}{len(eigs)}\n")
276-
for e in eigs:
277-
file.write(f"{sign * float(e):18.8f}\n")
276+
file.writelines(f"{sign * float(e):18.8f}\n" for e in eigs)
278277

279278
else:
280279
for i, kpt in enumerate(self._bs.kpoints):
@@ -301,8 +300,7 @@ def write_energy(self, output_file) -> None:
301300
a, b, c = kpt.frac_coords
302301
file.write(f"{a:12.8f} {b:12.8f} {c:12.8f} {len(eigs)}\n")
303302

304-
for e in eigs:
305-
file.write(f"{float(e):18.8f}\n")
303+
file.writelines(f"{float(e):18.8f}\n" for e in eigs)
306304

307305
def write_struct(self, output_file) -> None:
308306
"""Write the structure to an output file.
@@ -332,8 +330,7 @@ def write_struct(self, output_file) -> None:
332330
file.write(f"{len(ops)}\n")
333331

334332
for op in ops:
335-
for row in op:
336-
file.write(f"{' '.join(map(str, row))}\n")
333+
file.writelines(f"{' '.join(map(str, row))}\n" for row in op)
337334

338335
def write_def(self, output_file) -> None:
339336
"""Write the def to an output file.
@@ -392,8 +389,7 @@ def write_proj(self, output_file_proj: str, output_file_def: str) -> None:
392389
tmp_proj.append(self._hl)
393390
a, b, c = kpt.frac_coords
394391
file.write(f"{a:12.8f} {b:12.8f} {c:12.8f} {len(tmp_proj)}\n")
395-
for t in tmp_proj:
396-
file.write(f"{float(t):18.8f}\n")
392+
file.writelines(f"{float(t):18.8f}\n" for t in tmp_proj)
397393
with open(output_file_def, mode="w", encoding="utf-8") as file:
398394
so = ""
399395
if self._bs.is_spin_polarized:
@@ -451,10 +447,8 @@ def write_intrans(self, output_file) -> None:
451447
fout.write(f"{self.tauref} {self.tauexp} {self.tauen} 0 0 0\n")
452448
fout.write(f"{2 * len(self.doping)}\n")
453449

454-
for d in self.doping:
455-
fout.write(str(d) + "\n")
456-
for d in self.doping:
457-
fout.write(str(-d) + "\n")
450+
fout.writelines(str(d) + "\n" for d in self.doping)
451+
fout.writelines(str(-d) + "\n" for d in self.doping)
458452

459453
elif self.run_type == "FERMI":
460454
with open(output_file, mode="w", encoding="utf-8") as fout:

src/pymatgen/io/abinit/abitimer.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -701,8 +701,7 @@ def to_csv(self, fileobj=sys.stdout):
701701
if is_str:
702702
fileobj = open(fileobj, mode="w", encoding="utf-8") # noqa: SIM115
703703

704-
for idx, section in enumerate(self.sections):
705-
fileobj.write(section.to_csvline(with_header=(idx == 0)))
704+
fileobj.writelines(section.to_csvline(with_header=(idx == 0)) for idx, section in enumerate(self.sections))
706705
fileobj.flush()
707706

708707
if is_str:

src/pymatgen/io/adf.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,8 +551,7 @@ def write_file(self, molecule, inp_file):
551551
mol_blocks.append(unres_block)
552552

553553
with open(inp_file, "w+", encoding="utf-8") as file:
554-
for block in mol_blocks:
555-
file.write(str(block) + "\n")
554+
file.writelines(str(block) + "\n" for block in mol_blocks)
556555
file.write(str(self.task) + "\n")
557556
file.write("END INPUT")
558557

src/pymatgen/io/lammps/utils.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,7 @@ def _write_input(self, input_dir: str = ".") -> None:
265265
input_dir (str): path to the input directory
266266
"""
267267
with open(f"{input_dir}/{self.input_file}", mode="w", encoding="utf-8") as inp:
268-
for key, val in self.control_params.items():
269-
inp.write(f"{key} {self._format_param_val(val)}\n")
268+
inp.writelines(f"{key} {self._format_param_val(val)}\n" for key, val in self.control_params.items())
270269
# write the structures of the constituent molecules to file and set
271270
# the molecule id and the corresponding filename in the packmol
272271
# input file.
@@ -287,8 +286,7 @@ def _write_input(self, input_dir: str = ".") -> None:
287286

288287
inp.write("\n")
289288
inp.write(f"structure {os.path.join(input_dir, str(idx))}.{self.control_params['filetype']}\n")
290-
for key, val in self.param_list[idx].items():
291-
inp.write(f" {key} {self._format_param_val(val)}\n")
289+
inp.writelines(f" {key} {self._format_param_val(val)}\n" for key, val in self.param_list[idx].items())
292290
inp.write("end structure\n")
293291

294292
def run(self, site_property: str | None = None) -> Molecule:

src/pymatgen/io/lobster/inputs.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,7 @@ def write_lobsterin(
271271
file.write(f"{type(self).BOOLEAN_KEYWORDS[key]}\n")
272272

273273
elif key in type(self).LIST_KEYWORDS:
274-
for value in self.get(key): # type: ignore[union-attr]
275-
file.write(f"{type(self).LIST_KEYWORDS[key]} {value}\n")
274+
file.writelines(f"{type(self).LIST_KEYWORDS[key]} {value}\n" for value in self.get(key))
276275

277276
def as_dict(self) -> dict:
278277
"""MSONable dict."""

src/pymatgen/io/optimade.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def get_structure(resource: dict) -> Structure:
173173
if "attributes" not in resource:
174174
resource = {"attributes": resource}
175175

176-
_id = resource.get("id", None)
176+
_id = resource.get("id")
177177
attributes = resource["attributes"]
178178
properties: dict[str, Any] = {"optimade_id": _id}
179179

0 commit comments

Comments
 (0)