Skip to content

Commit

Permalink
ruff check pymatgen/io/vasp --select ANN204 --unsafe-fixes --fix
Browse files Browse the repository at this point in the history
  • Loading branch information
janosh committed Apr 12, 2024
1 parent a3ac1b5 commit bedb74f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion pymatgen/core/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def coincidents(self) -> list[Site]:
coincident_sites.append(self.sites[idx])
return coincident_sites

def __str__(self):
def __str__(self) -> str:
comp = self.composition
outs = [
f"Gb Summary ({comp.formula})",
Expand Down
2 changes: 1 addition & 1 deletion pymatgen/io/vasp/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class VaspDoc:
"""A VASP documentation helper."""

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

Expand Down
20 changes: 10 additions & 10 deletions pymatgen/io/vasp/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def __init__(
predictor_corrector_preamble: str | None = None,
lattice_velocities: ArrayLike | None = None,
sort_structure: bool = False,
):
) -> None:
"""
Args:
structure (Structure): Structure object.
Expand Down Expand Up @@ -211,7 +211,7 @@ def natoms(self) -> list[int]:
syms = [site.specie.symbol for site in self.structure]
return [len(tuple(a[1])) for a in itertools.groupby(syms)]

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

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

def __repr__(self):
def __repr__(self) -> str:
return self.get_str()

def __str__(self):
def __str__(self) -> str:
"""String representation of Poscar file."""
return self.get_str()

Expand Down Expand Up @@ -677,7 +677,7 @@ class Incar(dict, MSONable):
a dictionary with some helper functions.
"""

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

self.update(params)

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

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

def write_file(self, filename: PathLike):
Expand Down Expand Up @@ -993,7 +993,7 @@ class KpointsSupportedModes(Enum):
Cartesian = 4
Reciprocal = 5

def __str__(self):
def __str__(self) -> str:
return str(self.name)

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

def __repr__(self):
def __repr__(self) -> str:
lines = [self.comment, str(self.num_kpts), self.style.name]
style = self.style.name.lower()[0]
if style == "l":
Expand Down
22 changes: 11 additions & 11 deletions pymatgen/io/vasp/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1573,7 +1573,7 @@ def __init__(
parse_potcar_file: bool | str = False,
occu_tol: float = 1e-8,
separate_spins: bool = False,
):
) -> None:
"""
Args:
filename: Filename to parse
Expand Down Expand Up @@ -1814,7 +1814,7 @@ class Outcar:
Authors: Rickard Armiento, Shyue Ping Ong
"""

def __init__(self, filename):
def __init__(self, filename) -> None:
"""
Args:
filename (str): OUTCAR filename to parse.
Expand Down Expand Up @@ -3638,7 +3638,7 @@ def from_file(cls, filename: str, **kwargs) -> Self:
class Chgcar(VolumetricData):
"""Simple object for reading a CHGCAR file."""

def __init__(self, poscar, data, data_aug=None):
def __init__(self, poscar, data, data_aug=None) -> None:
"""
Args:
poscar (Poscar | Structure): Object containing structure.
Expand Down Expand Up @@ -3689,7 +3689,7 @@ class Elfcar(VolumetricData):
This also contains information on the kinetic energy density.
"""

def __init__(self, poscar, data):
def __init__(self, poscar, data) -> None:
"""
Args:
poscar (Poscar or Structure): Object containing structure.
Expand Down Expand Up @@ -3751,7 +3751,7 @@ class Procar:
nions (int): Number of ions.
"""

def __init__(self, filename):
def __init__(self, filename) -> None:
"""
Args:
filename: Name of file containing PROCAR.
Expand Down Expand Up @@ -3894,7 +3894,7 @@ class Oszicar:
depending on the type of VASP run.
"""

def __init__(self, filename):
def __init__(self, filename) -> None:
"""
Args:
filename (str): Filename of file to parse.
Expand Down Expand Up @@ -4025,7 +4025,7 @@ class Xdatcar:
Authors: Ram Balachandran
"""

def __init__(self, filename, ionicstep_start=1, ionicstep_end=None, comment=None):
def __init__(self, filename, ionicstep_start=1, ionicstep_end=None, comment=None) -> None:
"""
Init a Xdatcar.
Expand Down Expand Up @@ -4227,7 +4227,7 @@ def write_file(self, filename, **kwargs):
with zopen(filename, mode="wt") as file:
file.write(self.get_str(**kwargs))

def __str__(self):
def __str__(self) -> str:
return self.get_str()


Expand All @@ -4245,7 +4245,7 @@ class Dynmat:
Authors: Patrick Huck
"""

def __init__(self, filename):
def __init__(self, filename) -> None:
"""
Args:
filename: Name of file containing DYNMAT.
Expand Down Expand Up @@ -4398,7 +4398,7 @@ class Wavecar:
Author: Mark Turiansky
"""

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

def __init__(self, filename, occu_tol=1e-8, separate_spins=False):
def __init__(self, filename, occu_tol=1e-8, separate_spins=False) -> None:
"""
Reads input from filename to construct Eigenval object.
Expand Down
6 changes: 3 additions & 3 deletions pymatgen/io/vasp/sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1040,10 +1040,10 @@ def from_prev_calc(cls, prev_calc_dir: str, **kwargs) -> Self:
input_set = cls(_dummy_structure, **kwargs)
return input_set.override_from_prev_calc(prev_calc_dir=prev_calc_dir)

def __str__(self):
def __str__(self) -> str:
return type(self).__name__

def __repr__(self):
def __repr__(self) -> str:
return type(self).__name__

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

def __init__(self, structures, unset_encut=False, **kwargs):
def __init__(self, structures, unset_encut=False, **kwargs) -> None:
"""
Args:
structures: List of Structure objects.
Expand Down

0 comments on commit bedb74f

Please sign in to comment.