Skip to content

Commit

Permalink
finalized documentation issues and PEP 585
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Papior <[email protected]>
  • Loading branch information
zerothi committed Aug 8, 2024
1 parent 41e9d62 commit 686ef03
Show file tree
Hide file tree
Showing 21 changed files with 47 additions and 36 deletions.
3 changes: 3 additions & 0 deletions docs/api/typing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The typing types are shown below:
.. autosummary::
:toctree: generated/

AxisIntLiteral
CellAxisStrLiteral
CellAxisLiteral
CartesianAxisStrLiteral
Expand All @@ -34,7 +35,9 @@ The typing types are shown below:
.. autosummary::
:toctree: generated/

AtomLike
AtomsLike
CellLike
Coord
CoordOrScalar
FuncType
Expand Down
3 changes: 2 additions & 1 deletion src/sisl/_core/_ufuncs_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
from __future__ import annotations

from collections.abc import Callable
from functools import reduce
from numbers import Integral
from typing import Callable, Literal, Optional, Union
from typing import Literal, Optional, Union

import numpy as np

Expand Down
6 changes: 3 additions & 3 deletions src/sisl/_core/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ class Geometry(
def __init__(
self,
xyz: npt.ArrayLike,
atoms: AtomsLike = None,
lattice: LatticeLike = None,
atoms: Optional[AtomsLike] = None,
lattice: Optional[LatticeLike] = None,
names=None,
):
# Create the geometry coordinate, be aware that we do not copy!
Expand All @@ -206,7 +206,7 @@ def __init__(

self._init_lattice(lattice)

def _init_lattice(self, lattice: LatticeLike) -> None:
def _init_lattice(self, lattice: Optional[LatticeLike]) -> None:
"""Initializes the supercell by *calculating* the size if not supplied
If the supercell has not been passed we estimate the unit cell size
Expand Down
3 changes: 2 additions & 1 deletion src/sisl/_environ.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
from __future__ import annotations

import os
from collections.abc import Callable
from contextlib import contextmanager
from pathlib import Path
from textwrap import dedent
from typing import Any, Callable
from typing import Any

__all__ = ["register_environ_variable", "get_environ_variable", "sisl_environ"]

Expand Down
3 changes: 2 additions & 1 deletion src/sisl/io/_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
from __future__ import annotations

import warnings
from collections.abc import Callable
from functools import wraps
from typing import Callable, Optional, Union
from typing import Optional, Union

from sisl._internal import set_module
from sisl.messages import SislError, SislException, SislInfo, SislWarning, info, warn
Expand Down
3 changes: 2 additions & 1 deletion src/sisl/io/_multiple.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
from __future__ import annotations

from collections.abc import Callable
from functools import reduce, update_wrapper
from itertools import zip_longest
from numbers import Integral
from textwrap import dedent
from typing import Any, Callable, Optional
from typing import Any, Optional

Func = Callable[..., Optional[Any]]

Expand Down
3 changes: 2 additions & 1 deletion src/sisl/io/sile.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
import gzip
import logging
import re
from collections.abc import Callable
from functools import wraps
from io import TextIOBase
from itertools import product
from operator import contains
from os.path import basename, splitext
from pathlib import Path
from textwrap import dedent, indent
from typing import Any, Callable, Optional, Union
from typing import Any, Optional, Union

import sisl.io._exceptions as _exceptions
from sisl._environ import get_environ_variable
Expand Down
4 changes: 2 additions & 2 deletions src/sisl/mixing/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import operator as op
from abc import abstractmethod
from collections import deque
from collections.abc import Iterator, Sequence
from collections.abc import Callable, Iterator, Sequence
from numbers import Integral
from typing import Any, Callable, Optional, TypeVar, Union
from typing import Any, Optional, TypeVar, Union

from sisl._internal import set_module

Expand Down
3 changes: 2 additions & 1 deletion src/sisl/physics/electron.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@
"""
from __future__ import annotations

from collections.abc import Callable
from functools import reduce
from typing import TYPE_CHECKING, Callable, Literal, Optional, Union
from typing import TYPE_CHECKING, Literal, Optional, Union

import numpy as np
import numpy.typing as npt
Expand Down
3 changes: 2 additions & 1 deletion src/sisl/physics/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
from __future__ import annotations

from collections.abc import Callable
from functools import singledispatchmethod
from typing import Callable, Literal, Optional
from typing import Literal, Optional

import numpy as np
import numpy.typing as npt
Expand Down
10 changes: 2 additions & 8 deletions src/sisl/typing/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
from __future__ import annotations

from collections.abc import Sequence
from typing import TYPE_CHECKING, Any, Callable, Union
from collections.abc import Callable, Sequence
from typing import TYPE_CHECKING, Any, Union

import scipy.sparse as sps

Expand All @@ -19,7 +19,6 @@
"CoordOrScalar",
"FuncType",
"KPoint",
"LatticeOrGeometry",
"SeqFloat",
"SeqOrScalarFloat",
"SparseMatrix",
Expand All @@ -38,11 +37,6 @@
# Short for *any* function
FuncType = Callable[..., Any]

LatticeOrGeometry = Union[
"Lattice",
"Geometry",
]

if hasattr(sps, "sparray"):
SparseMatrixExt = Union[
sps.spmatrix,
Expand Down
6 changes: 6 additions & 0 deletions src/sisl/typing/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"CellLike",
"GeometryLike",
"LatticeLike",
"LatticeOrGeometry",
"LatticeOrGeometryLike",
"GridLike",
]
Expand Down Expand Up @@ -50,6 +51,11 @@
"""Data-types that can be converted to a `Grid`"""


LatticeOrGeometry = Union[
"Lattice",
"Geometry",
]

LatticeOrGeometryLike = Union[
LatticeLike,
GeometryLike,
Expand Down
4 changes: 2 additions & 2 deletions src/sisl/viz/plots/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
from __future__ import annotations

from collections.abc import Sequence
from typing import Callable, Literal, Optional, TypeVar, Union
from collections.abc import Callable, Sequence
from typing import Literal, Optional, TypeVar, Union

import numpy as np

Expand Down
4 changes: 2 additions & 2 deletions src/sisl/viz/plots/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from __future__ import annotations

from collections import ChainMap
from collections.abc import Sequence
from typing import Callable, Literal, Optional, Union
from collections.abc import Callable, Sequence
from typing import Literal, Optional, Union

from sisl._core import Geometry, Grid

Expand Down
4 changes: 2 additions & 2 deletions src/sisl/viz/processors/atom.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
from __future__ import annotations

from collections.abc import Sequence
from typing import Any, Callable, Optional, Union
from collections.abc import Callable, Sequence
from typing import Any, Optional, Union

import numpy as np
from xarray import DataArray, Dataset
Expand Down
4 changes: 2 additions & 2 deletions src/sisl/viz/processors/axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from __future__ import annotations

import re
from collections.abc import Sequence
from typing import Callable, Optional, Union
from collections.abc import Callable, Sequence
from typing import Optional, Union

import numpy as np

Expand Down
3 changes: 2 additions & 1 deletion src/sisl/viz/processors/coords.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
from __future__ import annotations

from typing import Callable, Optional, Union
from collections.abc import Callable
from typing import Optional, Union

import numpy as np
import numpy.typing as npt
Expand Down
4 changes: 2 additions & 2 deletions src/sisl/viz/processors/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
from __future__ import annotations

from collections.abc import Sequence
from typing import Callable, Literal, Optional, Union
from collections.abc import Callable, Sequence
from typing import Literal, Optional, Union

import numpy as np
import numpy.typing as npt
Expand Down
4 changes: 2 additions & 2 deletions src/sisl/viz/processors/orbital.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
# from __future__ import annotations

from collections import ChainMap, defaultdict
from collections.abc import Sequence
from collections.abc import Callable, Sequence
from dataclasses import asdict, is_dataclass
from pathlib import Path
from typing import Any, Callable, Optional, TypedDict, Union
from typing import Any, Optional, TypedDict, Union

import numpy as np
import xarray
Expand Down
4 changes: 2 additions & 2 deletions src/sisl/viz/processors/xarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
# from __future__ import annotations

from collections import defaultdict
from collections.abc import Sequence
from collections.abc import Callable, Sequence
from functools import singledispatchmethod
from typing import Any, Callable, Optional, TypedDict, Union
from typing import Any, Optional, TypedDict, Union

import numpy as np
import xarray as xr
Expand Down
2 changes: 1 addition & 1 deletion src/sisl_toolbox/cli/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

import argparse
import sys
from collections.abc import Callable
from pathlib import Path
from typing import Callable


class SToolBoxCLI:
Expand Down

0 comments on commit 686ef03

Please sign in to comment.