Skip to content

Commit f438df6

Browse files
committed
Serious technical debt in type checking.
1 parent 92b1cfb commit f438df6

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/pymatgen/core/structure.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ def add_oxidation_state_by_guess(self, **kwargs) -> Self:
697697
**kwargs: parameters to pass into oxi_state_guesses()
698698
"""
699699
oxi_guess = self.composition.oxi_state_guesses(**kwargs)
700-
oxi_guess = oxi_guess or [{e.symbol: 0 for e in self.composition}]
700+
oxi_guess = oxi_guess or [{e.symbol: 0 for e in self.composition}] # type:ignore[assignment]
701701
self.add_oxidation_state_by_element(oxi_guess[0])
702702

703703
return self
@@ -749,7 +749,7 @@ def remove_spin(self) -> Self:
749749
new_sp: dict[Element, float] = defaultdict(float)
750750
for sp, occu in site.species.items():
751751
oxi_state = getattr(sp, "oxi_state", None)
752-
new_sp[Species(sp.symbol, oxidation_state=oxi_state)] += occu
752+
new_sp[Species(sp.symbol, oxidation_state=oxi_state)] += occu # type:ignore[index]
753753
site.species = Composition(new_sp)
754754

755755
return self
@@ -1014,9 +1014,9 @@ class IStructure(SiteCollection, MSONable):
10141014

10151015
def __init__(
10161016
self,
1017-
lattice: ArrayLike | Lattice,
1017+
lattice: NDArray[np.float64] | Lattice,
10181018
species: Sequence[CompositionLike],
1019-
coords: Sequence[ArrayLike],
1019+
coords: Sequence[NDArray[np.float64]],
10201020
charge: float | None = None,
10211021
validate_proximity: bool = False,
10221022
to_unit_cell: bool = False,
@@ -1352,7 +1352,7 @@ def from_spacegroup(
13521352
props = {} if site_properties is None else site_properties
13531353

13541354
all_sp: list[str | Element | Species | DummySpecies | Composition] = []
1355-
all_coords: list[list[float]] = []
1355+
all_coords: list[NDArray[np.float64]] = []
13561356
all_site_properties: dict[str, list] = defaultdict(list)
13571357
all_labels: list[str | None] = []
13581358
for idx, (sp, c) in enumerate(zip(species, frac_coords, strict=True)):
@@ -3106,7 +3106,7 @@ def from_str( # type:ignore[override]
31063106
from pymatgen.io.cssr import Cssr
31073107

31083108
cssr = Cssr.from_str(input_string, **kwargs)
3109-
struct = cssr.structure
3109+
struct = cssr.structure # type:ignore[assignment]
31103110
elif fmt_low == "json":
31113111
dct = json.loads(input_string)
31123112
struct = Structure.from_dict(dct)
@@ -3125,7 +3125,7 @@ def from_str( # type:ignore[override]
31253125
elif fmt == "aims":
31263126
from pymatgen.io.aims.inputs import AimsGeometryIn
31273127

3128-
struct = AimsGeometryIn.from_str(input_string).structure
3128+
struct = AimsGeometryIn.from_str(input_string).structure # type:ignore[assignment]
31293129
# fleur support implemented in external namespace pkg https://github.com/JuDFTteam/pymatgen-io-fleur
31303130
elif fmt == "fleur-inpgen":
31313131
from pymatgen.io.fleur import FleurInput
@@ -3190,7 +3190,7 @@ def from_file( # type:ignore[override]
31903190

31913191
fname = os.path.basename(filename)
31923192
with zopen(filename, mode="rt", errors="replace", encoding="utf-8") as file:
3193-
contents: str = file.read()
3193+
contents: str = file.read() # type:ignore[assignment]
31943194
if fnmatch(fname.lower(), "*.cif*") or fnmatch(fname.lower(), "*.mcif*"):
31953195
return cls.from_str(
31963196
contents,
@@ -3257,7 +3257,7 @@ def from_file( # type:ignore[override]
32573257
elif fnmatch(fname, "input*.xml"):
32583258
from pymatgen.io.exciting import ExcitingInput
32593259

3260-
return ExcitingInput.from_file(fname, **kwargs).structure
3260+
return ExcitingInput.from_file(fname, **kwargs).structure # type:ignore[assignment]
32613261
elif fnmatch(fname, "*rndstr.in*") or fnmatch(fname, "*lat.in*") or fnmatch(fname, "*bestsqs*"):
32623262
return cls.from_str(
32633263
contents,
@@ -3270,7 +3270,7 @@ def from_file( # type:ignore[override]
32703270
elif fnmatch(fname, "CTRL*"):
32713271
from pymatgen.io.lmto import LMTOCtrl
32723272

3273-
return LMTOCtrl.from_file(filename=filename, **kwargs).structure
3273+
return LMTOCtrl.from_file(filename=filename, **kwargs).structure # type:ignore[assignment]
32743274
elif fnmatch(fname, "geometry.in*"):
32753275
return cls.from_str(
32763276
contents,
@@ -5228,7 +5228,7 @@ def insert( # type:ignore[override]
52285228
self,
52295229
idx: int,
52305230
species: CompositionLike,
5231-
coords: ArrayLike,
5231+
coords: NDArray[np.float64],
52325232
validate_proximity: bool = False,
52335233
properties: dict | None = None,
52345234
label: str | None = None,

0 commit comments

Comments
 (0)