Skip to content

Commit 1e30153

Browse files
committed
ci: Use ty instead of mypy
1 parent 40a4770 commit 1e30153

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

src/griffe2md/_internal/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def render_package_docs(package: str, config: ConfigDict | None = None, *, forma
166166
)
167167
module = loader.load(package)
168168
loader.resolve_aliases(external=True)
169-
return render_object_docs(module, config, format_md=format_md) # type: ignore[arg-type]
169+
return render_object_docs(module, config, format_md=format_md) # ty: ignore[invalid-argument-type]
170170

171171

172172
def write_package_docs(

src/griffe2md/_internal/rendering.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def _stash_crossref(stash: dict[str, str], crossref: str, *, length: int) -> str
118118

119119

120120
def _format_signature(name: Markup, signature: str, line_length: int) -> str:
121-
name = str(name).strip() # type: ignore[assignment]
121+
name = str(name).strip() # ty: ignore[invalid-assignment]
122122
signature = signature.strip()
123123
if len(name + signature) < line_length:
124124
return name + signature
@@ -372,7 +372,7 @@ def do_filter_objects(
372372
@lru_cache(maxsize=1)
373373
def _get_black_formatter() -> Callable[[str, int], str]:
374374
try:
375-
from black import InvalidInput, Mode, format_str # noqa: PLC0415
375+
from black import InvalidInput, Mode, format_str # noqa: PLC0415 # ty: ignore[unresolved-import]
376376
except ModuleNotFoundError:
377377
_logger.info("Formatting signatures requires Black to be installed.")
378378
return lambda text, _: text
@@ -401,7 +401,7 @@ def from_private_package(obj: Object | Alias) -> bool:
401401
if not obj.is_alias:
402402
return False
403403
try:
404-
return obj.target.package.name == f"_{obj.parent.package.name}" # type: ignore[union-attr]
404+
return obj.target.package.name == f"_{obj.parent.package.name}" # ty: ignore[possibly-missing-attribute]
405405
except (AliasResolutionError, CyclicAliasError):
406406
return False
407407

tests/test_config.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
"""Test config loading."""
22

3+
from __future__ import annotations
4+
35
from pathlib import Path
6+
from typing import TYPE_CHECKING
47
from unittest.mock import Mock, patch
58

69
import pytest
710

811
import griffe2md
912

13+
if TYPE_CHECKING:
14+
import py
15+
1016

1117
@pytest.mark.parametrize("rel_path", griffe2md.CONFIG_FILE_PATHS)
12-
def test_load_config(tmpdir: Path, rel_path: Path) -> None:
18+
def test_load_config(tmpdir: py.path.local, rel_path: Path) -> None:
1319
"""Test that config is loaded."""
1420
expected_config = {"dummy": True}
1521
config_text = "dummy=true"
1622

1723
mock_write = Mock()
1824

19-
with tmpdir.as_cwd(), patch("griffe2md._internal.cli.write_package_docs", mock_write): # type: ignore[attr-defined]
25+
with tmpdir.as_cwd(), patch("griffe2md._internal.cli.write_package_docs", mock_write):
2026
text = f"[tool.griffe2md]\n{config_text}" if rel_path.name == "pyproject.toml" else config_text
2127
config_path = Path(tmpdir) / rel_path
2228
config_path.parent.mkdir(parents=True, exist_ok=True)

0 commit comments

Comments
 (0)