Skip to content

Commit

Permalink
Typing
Browse files Browse the repository at this point in the history
  • Loading branch information
kavanase committed Jan 17, 2025
1 parent 600104e commit db1cbe6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/pymatgen/core/composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def __init__(self, *args, strict: bool = False, **kwargs) -> None:
else:
elem_map = dict(*args, **kwargs) # type: ignore[assignment]
elem_amt = {}
self._n_atoms = 0
self._n_atoms: int | float = 0
for key, val in elem_map.items():
if val < -type(self).amount_tolerance and not self.allow_negative:
raise ValueError("Amounts in Composition cannot be negative!")
Expand All @@ -184,7 +184,7 @@ def __init__(self, *args, strict: bool = False, **kwargs) -> None:
if strict and not self.valid:
raise ValueError(f"Composition is not valid, contains: {', '.join(map(str, self.elements))}")

def __getitem__(self, key: SpeciesLike) -> float:
def __getitem__(self, key: SpeciesLike) -> int | float:
try:
sp = get_el_sp(key)
if isinstance(sp, Species):
Expand All @@ -202,7 +202,7 @@ def __len__(self) -> int:
def __iter__(self) -> Iterator[Species | Element | DummySpecies]:
return iter(self._data)

def items(self) -> ItemsView[Species | Element | DummySpecies, float]:
def items(self) -> ItemsView[Species | Element | DummySpecies, int | float]:
"""Returns Dict.items() for the Composition dict."""
return self._data.items()

Expand Down

0 comments on commit db1cbe6

Please sign in to comment.