Skip to content

Commit bedb74f

Browse files
committed
ruff check pymatgen/io/vasp --select ANN204 --unsafe-fixes --fix
1 parent a3ac1b5 commit bedb74f

File tree

5 files changed

+26
-26
lines changed

5 files changed

+26
-26
lines changed

pymatgen/core/interface.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def coincidents(self) -> list[Site]:
244244
coincident_sites.append(self.sites[idx])
245245
return coincident_sites
246246

247-
def __str__(self):
247+
def __str__(self) -> str:
248248
comp = self.composition
249249
outs = [
250250
f"Gb Summary ({comp.formula})",

pymatgen/io/vasp/help.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
class VaspDoc:
1212
"""A VASP documentation helper."""
1313

14-
def __init__(self):
14+
def __init__(self) -> None:
1515
"""Init for VaspDoc."""
1616
self.url_template = "http://www.vasp.at/wiki/index.php/%s"
1717

pymatgen/io/vasp/inputs.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def __init__(
8787
predictor_corrector_preamble: str | None = None,
8888
lattice_velocities: ArrayLike | None = None,
8989
sort_structure: bool = False,
90-
):
90+
) -> None:
9191
"""
9292
Args:
9393
structure (Structure): Structure object.
@@ -211,7 +211,7 @@ def natoms(self) -> list[int]:
211211
syms = [site.specie.symbol for site in self.structure]
212212
return [len(tuple(a[1])) for a in itertools.groupby(syms)]
213213

214-
def __setattr__(self, name, value):
214+
def __setattr__(self, name, value) -> None:
215215
if name in ("selective_dynamics", "velocities") and value is not None and len(value) > 0:
216216
value = np.array(value)
217217
dim = value.shape
@@ -577,10 +577,10 @@ def get_str(self, direct: bool = True, vasp4_compatible: bool = False, significa
577577

578578
return "\n".join(lines) + "\n"
579579

580-
def __repr__(self):
580+
def __repr__(self) -> str:
581581
return self.get_str()
582582

583-
def __str__(self):
583+
def __str__(self) -> str:
584584
"""String representation of Poscar file."""
585585
return self.get_str()
586586

@@ -677,7 +677,7 @@ class Incar(dict, MSONable):
677677
a dictionary with some helper functions.
678678
"""
679679

680-
def __init__(self, params: dict[str, Any] | None = None):
680+
def __init__(self, params: dict[str, Any] | None = None) -> None:
681681
"""
682682
Creates an Incar object.
683683
@@ -698,7 +698,7 @@ def __init__(self, params: dict[str, Any] | None = None):
698698

699699
self.update(params)
700700

701-
def __setitem__(self, key: str, val: Any):
701+
def __setitem__(self, key: str, val: Any) -> None:
702702
"""
703703
Add parameter-val pair to Incar. Warns if parameter is not in list of
704704
valid INCAR tags. Also cleans the parameter and val by stripping
@@ -771,7 +771,7 @@ def get_str(self, sort_keys: bool = False, pretty: bool = False) -> str:
771771
return str(tabulate([[line[0], "=", line[1]] for line in lines], tablefmt="plain"))
772772
return str_delimited(lines, None, " = ") + "\n"
773773

774-
def __str__(self):
774+
def __str__(self) -> str:
775775
return self.get_str(sort_keys=True, pretty=False)
776776

777777
def write_file(self, filename: PathLike):
@@ -993,7 +993,7 @@ class KpointsSupportedModes(Enum):
993993
Cartesian = 4
994994
Reciprocal = 5
995995

996-
def __str__(self):
996+
def __str__(self) -> str:
997997
return str(self.name)
998998

999999
@classmethod
@@ -1030,7 +1030,7 @@ def __init__(
10301030
tet_number: int = 0,
10311031
tet_weight: float = 0,
10321032
tet_connections=None,
1033-
):
1033+
) -> None:
10341034
"""
10351035
Highly flexible constructor for Kpoints object. The flexibility comes
10361036
at the cost of usability and in general, it is recommended that you use
@@ -1484,7 +1484,7 @@ def write_file(self, filename: str) -> None:
14841484
with zopen(filename, mode="wt") as file:
14851485
file.write(str(self))
14861486

1487-
def __repr__(self):
1487+
def __repr__(self) -> str:
14881488
lines = [self.comment, str(self.num_kpts), self.style.name]
14891489
style = self.style.name.lower()[0]
14901490
if style == "l":

pymatgen/io/vasp/outputs.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,7 +1573,7 @@ def __init__(
15731573
parse_potcar_file: bool | str = False,
15741574
occu_tol: float = 1e-8,
15751575
separate_spins: bool = False,
1576-
):
1576+
) -> None:
15771577
"""
15781578
Args:
15791579
filename: Filename to parse
@@ -1814,7 +1814,7 @@ class Outcar:
18141814
Authors: Rickard Armiento, Shyue Ping Ong
18151815
"""
18161816

1817-
def __init__(self, filename):
1817+
def __init__(self, filename) -> None:
18181818
"""
18191819
Args:
18201820
filename (str): OUTCAR filename to parse.
@@ -3638,7 +3638,7 @@ def from_file(cls, filename: str, **kwargs) -> Self:
36383638
class Chgcar(VolumetricData):
36393639
"""Simple object for reading a CHGCAR file."""
36403640

3641-
def __init__(self, poscar, data, data_aug=None):
3641+
def __init__(self, poscar, data, data_aug=None) -> None:
36423642
"""
36433643
Args:
36443644
poscar (Poscar | Structure): Object containing structure.
@@ -3689,7 +3689,7 @@ class Elfcar(VolumetricData):
36893689
This also contains information on the kinetic energy density.
36903690
"""
36913691

3692-
def __init__(self, poscar, data):
3692+
def __init__(self, poscar, data) -> None:
36933693
"""
36943694
Args:
36953695
poscar (Poscar or Structure): Object containing structure.
@@ -3751,7 +3751,7 @@ class Procar:
37513751
nions (int): Number of ions.
37523752
"""
37533753

3754-
def __init__(self, filename):
3754+
def __init__(self, filename) -> None:
37553755
"""
37563756
Args:
37573757
filename: Name of file containing PROCAR.
@@ -3894,7 +3894,7 @@ class Oszicar:
38943894
depending on the type of VASP run.
38953895
"""
38963896

3897-
def __init__(self, filename):
3897+
def __init__(self, filename) -> None:
38983898
"""
38993899
Args:
39003900
filename (str): Filename of file to parse.
@@ -4025,7 +4025,7 @@ class Xdatcar:
40254025
Authors: Ram Balachandran
40264026
"""
40274027

4028-
def __init__(self, filename, ionicstep_start=1, ionicstep_end=None, comment=None):
4028+
def __init__(self, filename, ionicstep_start=1, ionicstep_end=None, comment=None) -> None:
40294029
"""
40304030
Init a Xdatcar.
40314031
@@ -4227,7 +4227,7 @@ def write_file(self, filename, **kwargs):
42274227
with zopen(filename, mode="wt") as file:
42284228
file.write(self.get_str(**kwargs))
42294229

4230-
def __str__(self):
4230+
def __str__(self) -> str:
42314231
return self.get_str()
42324232

42334233

@@ -4245,7 +4245,7 @@ class Dynmat:
42454245
Authors: Patrick Huck
42464246
"""
42474247

4248-
def __init__(self, filename):
4248+
def __init__(self, filename) -> None:
42494249
"""
42504250
Args:
42514251
filename: Name of file containing DYNMAT.
@@ -4398,7 +4398,7 @@ class Wavecar:
43984398
Author: Mark Turiansky
43994399
"""
44004400

4401-
def __init__(self, filename="WAVECAR", verbose=False, precision="normal", vasp_type=None):
4401+
def __init__(self, filename="WAVECAR", verbose=False, precision="normal", vasp_type=None) -> None:
44024402
"""
44034403
Information is extracted from the given WAVECAR.
44044404
@@ -4881,7 +4881,7 @@ class Eigenval:
48814881
to be converted into proper objects. The kpoint index is 0-based (unlike the 1-based indexing in VASP).
48824882
"""
48834883

4884-
def __init__(self, filename, occu_tol=1e-8, separate_spins=False):
4884+
def __init__(self, filename, occu_tol=1e-8, separate_spins=False) -> None:
48854885
"""
48864886
Reads input from filename to construct Eigenval object.
48874887

pymatgen/io/vasp/sets.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,10 +1040,10 @@ def from_prev_calc(cls, prev_calc_dir: str, **kwargs) -> Self:
10401040
input_set = cls(_dummy_structure, **kwargs)
10411041
return input_set.override_from_prev_calc(prev_calc_dir=prev_calc_dir)
10421042

1043-
def __str__(self):
1043+
def __str__(self) -> str:
10441044
return type(self).__name__
10451045

1046-
def __repr__(self):
1046+
def __repr__(self) -> str:
10471047
return type(self).__name__
10481048

10491049
def write_input(
@@ -2271,7 +2271,7 @@ class MITNEBSet(DictSet):
22712271
Note that EDIFF is not on a per atom basis for this input set.
22722272
"""
22732273

2274-
def __init__(self, structures, unset_encut=False, **kwargs):
2274+
def __init__(self, structures, unset_encut=False, **kwargs) -> None:
22752275
"""
22762276
Args:
22772277
structures: List of Structure objects.

0 commit comments

Comments
 (0)