Skip to content

Commit

Permalink
fix mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
janosh committed Jul 31, 2023
1 parent 28a895f commit 185d2cb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pymatgen/core/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,9 @@ def __contains__(self, site: object) -> bool:
def __iter__(self) -> Iterator[Site]:
return self.sites.__iter__()

def __getitem__(self, ind):
return self.sites[ind]
# TODO return type needs fixing (can be list[Site] but raises lots of mypy errors)
def __getitem__(self, ind: int | slice) -> Site:
return self.sites[ind] # type: ignore[return-value]

def __len__(self) -> int:
return len(self.sites)
Expand Down Expand Up @@ -1375,7 +1376,8 @@ def get_distance(self, i: int, j: int, jimage=None) -> float:
Returns:
distance
"""
return self[i].distance(self[j], jimage)
site: PeriodicSite = self[i]
return site.distance(self[j], jimage)

def get_sites_in_sphere(
self,
Expand Down

0 comments on commit 185d2cb

Please sign in to comment.