Skip to content

Commit

Permalink
Fix mypy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ndaelman committed Oct 7, 2024
1 parent 0b573b4 commit e6f8bfb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
15 changes: 10 additions & 5 deletions src/nomad_simulations/schema_packages/model_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import re
from functools import lru_cache
from hashlib import sha1
from typing import TYPE_CHECKING, Optional
from typing import TYPE_CHECKING

import ase
import numpy as np
Expand All @@ -42,6 +42,9 @@
from nomad.units import ureg

if TYPE_CHECKING:
from collections.abc import Generator
from typing import Callable, Optional

import pint
from nomad.datamodel.datamodel import EntryArchive
from nomad.metainfo import Context, Section
Expand Down Expand Up @@ -229,7 +232,7 @@ def __init__(self, representative_variable):
def __hash__(self):
return self.representative_variable.__hash__()

def _check_implemented(func: callable):
def _check_implemented(func: Callable):
"""
Decorator to restrict the comparison functions to the same class.
"""
Expand Down Expand Up @@ -304,7 +307,7 @@ class Cell(GeometricSpace):
type=MEnum('original', 'primitive', 'conventional'),
description="""
Representation type of the cell structure. It might be:
- 'original' as in origanally parsed,
- 'original' as in originally parsed,
- 'primitive' as the primitive unit cell,
- 'conventional' as the conventional cell used for referencing.
""",
Expand Down Expand Up @@ -366,7 +369,7 @@ class Cell(GeometricSpace):
)

@staticmethod
def _generate_comparer(obj) -> tuple:
def _generate_comparer(obj) -> Generator[HashedPositions, None, None]:
try:
return (HashedPositions(pos) for pos in obj.positions)
except AttributeError:
Expand Down Expand Up @@ -440,7 +443,9 @@ def __init__(self, m_def: 'Section' = None, m_context: 'Context' = None, **kwarg
self.name = self.m_def.name

@staticmethod
def _generate_comparer(obj) -> tuple:
def _generate_comparer(
obj,
) -> Generator[HashedPositions, PartialOrderElement, None, None]:
# presumes `atoms_state` mapping 1-to-1 with `positions` and conserves the order
try:
return (
Expand Down
4 changes: 2 additions & 2 deletions src/nomad_simulations/schema_packages/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from nomad.config import config

if TYPE_CHECKING:
from typing import Optional
from typing import Callable, Optional

from nomad.datamodel.data import ArchiveSection
from structlog.stdlib import BoundLogger
Expand Down Expand Up @@ -177,7 +177,7 @@ def get_composition(children_names: 'list[str]') -> str:
return formula if formula else None


def catch_not_implemented(func: callable):
def catch_not_implemented(func: Callable):
"""
Decorator to default comparison functions outside the same class to `False`.
"""
Expand Down

0 comments on commit e6f8bfb

Please sign in to comment.