Skip to content

Commit

Permalink
build: add optional_dependencies (#8)
Browse files Browse the repository at this point in the history
Signed-off-by: nstarman <[email protected]>
  • Loading branch information
nstarman authored Sep 10, 2024
1 parent c0eb3cd commit 25c7f66
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
16 changes: 10 additions & 6 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

import platform
from doctest import ELLIPSIS, NORMALIZE_WHITESPACE
from importlib.util import find_spec

from sybil import Sybil
from sybil.parsers.rest import DocTestParser, PythonCodeBlockParser, SkipParser

from optional_dependencies import OptionalDependencyEnum, auto

# TODO: stop skipping doctests on Windows when there is uniform support for
# numpy 2.0+ scalar repr. On windows it is printed as 1.0 instead of
# `np.float64(1.0)`.
Expand All @@ -25,12 +26,15 @@
).pytest()


# TODO: via separate optional_deps package
HAS_ASTROPY = find_spec("astropy") is not None
HAS_GALA = find_spec("gala") is not None
class OptDeps(OptionalDependencyEnum): # type: ignore[misc] # pylint: disable=invalid-enum-extension
"""Optional dependencies for ``is_annotated``."""

ASTROPY = auto()
GALA = auto()


collect_ignore_glob = []
if not HAS_ASTROPY:
if not OptDeps.ASTROPY.installed:
collect_ignore_glob.append("src/unxt/_interop/unxt_interop_astropy/*")
if not HAS_GALA:
if not OptDeps.GALA.installed:
collect_ignore_glob.append("src/unxt/_interop/unxt_interop_gala/*")
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
[project.optional-dependencies]
dev = ["is_annotated[test]"]
test = [
"optional_dependencies >= 0.3",
"pytest >=6",
"pytest-cov >=3",
"pytest-github-actions-annotate-failures",
Expand Down Expand Up @@ -109,6 +110,12 @@
"noxfile.py" = ["T20"]
"tests/**" = ["ANN", "INP001", "S101", "T20"]

[tool.ruff.lint.isort]
combine-as-imports = true
extra-standard-library = ["typing_extensions"]
known-first-party = ["optional_dependencies"]
known-local-folder = ["is_annotated"]


[tool.pylint]
ignore-paths = [".*/_version.py"]
Expand Down
1 change: 0 additions & 1 deletion src/is_annotated/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
__all__ = ["isannotated"]

from typing import Annotated

from typing_extensions import TypeGuard, _AnnotatedAlias

AnnotationType = type(Annotated[int, "_"])
Expand Down

0 comments on commit 25c7f66

Please sign in to comment.