Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/griffelib/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ classifiers = [
# to download and inspect packages from PyPI.
pypi = ["pip>=24.0", "platformdirs>=4.2", "wheel>=0.42"]

[dependency-groups]
dev = ["pytest>=8.2", "pytest-gitconfig>=0.8.0", "jsonschema>=4.18"]

[tool.uv-dynamic-versioning]
pattern = '(?P<base>\d+\.\d+\.\d+)'

Expand Down
27 changes: 19 additions & 8 deletions packages/griffelib/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,46 @@
from typing import TYPE_CHECKING

import pytest
from mkdocstrings import Inventory

import griffe
import griffecli

try:
import griffecli
except ModuleNotFoundError:
griffecli = None

if TYPE_CHECKING:
from collections.abc import Iterable, Iterator
from types import ModuleType

from mkdocstrings import Inventory


TESTED_MODULES = (griffe, griffecli)
TESTED_MODULES = (griffe, griffecli) if griffecli else (griffe,)
_test_all_modules = pytest.mark.parametrize("tested_module", TESTED_MODULES)


@pytest.fixture(name="inventory", scope="module")
def _fixture_inventory() -> Inventory:
mkdocstrings = pytest.importorskip("mkdocstrings")
inventory_file = Path(__file__).parent.parent / "site" / "objects.inv"
if not inventory_file.exists():
pytest.skip("The objects inventory is not available.")

with inventory_file.open("rb") as file:
return Inventory.parse_sphinx(file)
return mkdocstrings.Inventory.parse_sphinx(file)


def _load_modules(*modules: ModuleType) -> griffe.GriffeLoader:
extensions = ["unpack_typeddict"]
try:
import griffe_inherited_docstrings # noqa: F401, PLC0415

extensions.append("griffe_inherited_docstrings")
except ImportError:
pass
loader = griffe.GriffeLoader(
extensions=griffe.load_extensions(
"griffe_inherited_docstrings",
"unpack_typeddict",
),
extensions=griffe.load_extensions(*extensions),
)
for module in modules:
loader.load(module.__name__)
Expand Down
5 changes: 4 additions & 1 deletion packages/griffelib/tests/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import pytest

from griffe import Module, check, load_git
from griffe import Module, load_git
from tests import FIXTURES_DIR

if TYPE_CHECKING:
Expand Down Expand Up @@ -117,4 +117,7 @@ def test_load_git_errors(git_repo: Path) -> None:

def test_git_failures(tmp_path: Path) -> None:
"""Test failures to use Git."""
pytest.importorskip("griffecli")
from griffe import check # noqa: PLC0415

assert check(tmp_path) == 2
Loading