diff --git a/pymatgen/analysis/chemenv/coordination_environments/voronoi.py b/pymatgen/analysis/chemenv/coordination_environments/voronoi.py index 851bb0da843..52e04ed586a 100644 --- a/pymatgen/analysis/chemenv/coordination_environments/voronoi.py +++ b/pymatgen/analysis/chemenv/coordination_environments/voronoi.py @@ -11,9 +11,6 @@ from monty.json import MSONable from scipy.spatial import Voronoi -if TYPE_CHECKING: - from typing_extensions import Self - from pymatgen.analysis.chemenv.utils.coordination_geometry_utils import ( get_lower_and_upper_f, rectangle_surface_intersection, @@ -24,6 +21,9 @@ from pymatgen.core.sites import PeriodicSite from pymatgen.core.structure import Structure +if TYPE_CHECKING: + from typing_extensions import Self + __author__ = "David Waroquiers" __copyright__ = "Copyright 2012, The Materials Project" __credits__ = "Geoffroy Hautier" diff --git a/pymatgen/analysis/molecule_matcher.py b/pymatgen/analysis/molecule_matcher.py index 8f51d234525..f834cb43c0c 100644 --- a/pymatgen/analysis/molecule_matcher.py +++ b/pymatgen/analysis/molecule_matcher.py @@ -27,9 +27,6 @@ from pymatgen.core.structure import Molecule -if TYPE_CHECKING: - from typing_extensions import Self - try: from openbabel import openbabel @@ -37,6 +34,9 @@ except ImportError: openbabel = None +if TYPE_CHECKING: + from typing_extensions import Self + __author__ = "Xiaohui Qu, Adam Fekete" __version__ = "1.0" diff --git a/pymatgen/electronic_structure/boltztrap2.py b/pymatgen/electronic_structure/boltztrap2.py index f15737eefbe..dc2fe479186 100644 --- a/pymatgen/electronic_structure/boltztrap2.py +++ b/pymatgen/electronic_structure/boltztrap2.py @@ -49,6 +49,7 @@ except ImportError: raise BoltztrapError("BoltzTraP2 has to be installed and working") + __author__ = "Francesco Ricci" __copyright__ = "Copyright 2018, The Materials Project" __version__ = "1.0" diff --git a/pymatgen/io/ase.py b/pymatgen/io/ase.py index 7d959179bf5..03ee711e58a 100644 --- a/pymatgen/io/ase.py +++ b/pymatgen/io/ase.py @@ -15,13 +15,6 @@ from pymatgen.core.structure import Molecule, Structure -if TYPE_CHECKING: - from typing import Any - - from numpy.typing import ArrayLike - - from pymatgen.core.structure import SiteCollection - try: from ase.atoms import Atoms from ase.calculators.singlepoint import SinglePointDFTCalculator @@ -38,6 +31,13 @@ def __init__(self, *args, **kwargs): raise no_ase_err +if TYPE_CHECKING: + from typing import Any + + from numpy.typing import ArrayLike + + from pymatgen.core.structure import SiteCollection + __author__ = "Shyue Ping Ong, Andrew S. Rosen" __copyright__ = "Copyright 2012, The Materials Project" __version__ = "1.0" diff --git a/pymatgen/io/lammps/utils.py b/pymatgen/io/lammps/utils.py index b36539ce46f..17b396ed24e 100644 --- a/pymatgen/io/lammps/utils.py +++ b/pymatgen/io/lammps/utils.py @@ -18,15 +18,16 @@ from pymatgen.io.packmol import PackmolBoxGen from pymatgen.util.coord import get_angle +try: + from openbabel import pybel +except ImportError: + pybel = None + if TYPE_CHECKING: from collections.abc import Sequence from numpy.typing import ArrayLike -try: - from openbabel import pybel -except ImportError: - pybel = None __author__ = "Kiran Mathew, Brandon Wood, Michael Humbert" __email__ = "kmathew@lbl.gov" diff --git a/pymatgen/io/vasp/outputs.py b/pymatgen/io/vasp/outputs.py index da434808e01..a1a09371d4c 100644 --- a/pymatgen/io/vasp/outputs.py +++ b/pymatgen/io/vasp/outputs.py @@ -42,11 +42,11 @@ from pymatgen.util.io_utils import clean_lines, micro_pyawk from pymatgen.util.num import make_symmetric_matrix_from_upper_tri -logger = logging.getLogger(__name__) - if TYPE_CHECKING: from typing_extensions import Self +logger = logging.getLogger(__name__) + def _parse_parameters(val_type, val): """ diff --git a/pymatgen/phonon/thermal_displacements.py b/pymatgen/phonon/thermal_displacements.py index 18ef9827d69..4640548e6f6 100644 --- a/pymatgen/phonon/thermal_displacements.py +++ b/pymatgen/phonon/thermal_displacements.py @@ -26,7 +26,6 @@ from numpy.typing import ArrayLike from typing_extensions import Self - __author__ = "J. George" __copyright__ = "Copyright 2022, The Materials Project" __version__ = "0.1" diff --git a/pymatgen/symmetry/analyzer.py b/pymatgen/symmetry/analyzer.py index 848ac4a8060..438160c278c 100644 --- a/pymatgen/symmetry/analyzer.py +++ b/pymatgen/symmetry/analyzer.py @@ -39,6 +39,7 @@ from pymatgen.symmetry.groups import CrystalSystem logger = logging.getLogger(__name__) + LatticeType = Literal["cubic", "hexagonal", "monoclinic", "orthorhombic", "rhombohedral", "tetragonal", "triclinic"] cite_conventional_cell_algo = due.dcite( diff --git a/pymatgen/util/provenance.py b/pymatgen/util/provenance.py index cd28d818521..26a301138fe 100644 --- a/pymatgen/util/provenance.py +++ b/pymatgen/util/provenance.py @@ -14,17 +14,18 @@ from pymatgen.core.structure import Molecule, Structure -if TYPE_CHECKING: - from collections.abc import Sequence - - from typing_extensions import Self - try: from pybtex import errors from pybtex.database.input import bibtex except ImportError: pybtex = bibtex = None +if TYPE_CHECKING: + from collections.abc import Sequence + + from typing_extensions import Self + + __author__ = "Anubhav Jain, Shyue Ping Ong" __credits__ = "Dan Gunter" diff --git a/pymatgen/vis/structure_vtk.py b/pymatgen/vis/structure_vtk.py index 33d6f28aad8..26c36af4c1b 100644 --- a/pymatgen/vis/structure_vtk.py +++ b/pymatgen/vis/structure_vtk.py @@ -16,9 +16,6 @@ from pymatgen.core import PeriodicSite, Species, Structure from pymatgen.util.coord import in_coord_list -if TYPE_CHECKING: - from collections.abc import Sequence - try: import vtk from vtk import vtkInteractorStyleTrackballCamera as TrackballCamera @@ -27,6 +24,9 @@ vtk = None TrackballCamera = object +if TYPE_CHECKING: + from collections.abc import Sequence + module_dir = os.path.dirname(os.path.abspath(__file__)) EL_COLORS = loadfn(f"{module_dir}/ElementColorSchemes.yaml") diff --git a/tests/core/test_settings.py b/tests/core/test_settings.py index c55774da641..eb0ba992bbf 100644 --- a/tests/core/test_settings.py +++ b/tests/core/test_settings.py @@ -2,12 +2,13 @@ from typing import TYPE_CHECKING +from pymatgen.core import _load_pmg_settings + if TYPE_CHECKING: from pathlib import Path from pytest import MonkeyPatch -from pymatgen.core import _load_pmg_settings __author__ = "Janosh Riebesell" __date__ = "2022-10-21"