Skip to content

Commit 68cd706

Browse files
committed
ci: Fix mypy warnings
1 parent 8cdcca3 commit 68cd706

4 files changed

Lines changed: 11 additions & 17 deletions

File tree

scripts/mkdocs_hooks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
try:
1515
from pydantic import TypeAdapter
1616
except ImportError:
17-
TypeAdapter = None
17+
TypeAdapter = None # type: ignore[assignment,misc]
1818

1919

2020
_logger = get_plugin_logger(__name__)
@@ -38,9 +38,9 @@ class CHandlerSchema:
3838
_logger.debug("Generated JSON schema")
3939

4040
autorefs = config["plugins"]["autorefs"]
41-
for field in fields(CInputConfig): # type: ignore[arg-type]
41+
for field in fields(CInputConfig):
4242
if f"setting-{field.name}" not in autorefs._primary_url_map:
4343
_logger.warning(f"Handler setting `{field.name}` is not documented")
44-
for field in fields(CInputOptions): # type: ignore[arg-type]
44+
for field in fields(CInputOptions):
4545
if f"option-{field.name}" not in autorefs._primary_url_map:
4646
_logger.warning(f"Configuration option `{field.name}` is not documented")

src/mkdocstrings_handlers/c/_internal/config.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def _add_markdown_description(schema: dict[str, Any]) -> None:
7373
**kwargs,
7474
)
7575
except ImportError:
76-
from dataclasses import dataclass
76+
from dataclasses import dataclass # type: ignore[no-redef]
7777

7878
def _Field(*args: Any, **kwargs: Any) -> None: # type: ignore[misc] # noqa: N802
7979
pass
@@ -91,7 +91,7 @@ def _Field(*args: Any, **kwargs: Any) -> None: # type: ignore[misc] # noqa: N8
9191

9292
# The input config class is useful to generate a JSON schema, see scripts/mkdocs_hooks.py.
9393
# YORE: EOL 3.9: Replace `**_dataclass_options` with `frozen=True, kw_only=True` within line.
94-
@dataclass(**_dataclass_options)
94+
@dataclass(**_dataclass_options) # type: ignore[call-overload]
9595
class CInputOptions:
9696
"""Accepted input options."""
9797

@@ -155,7 +155,7 @@ def from_data(cls, **data: Any) -> Self:
155155

156156

157157
# YORE: EOL 3.9: Replace `**_dataclass_options` with `frozen=True, kw_only=True` within line.
158-
@dataclass(**_dataclass_options)
158+
@dataclass(**_dataclass_options) # type: ignore[call-overload]
159159
class COptions(CInputOptions): # type: ignore[override,unused-ignore]
160160
"""Final options passed as template context."""
161161

@@ -170,7 +170,7 @@ def coerce(cls, **data: Any) -> MutableMapping[str, Any]:
170170

171171
# The input config class is useful to generate a JSON schema, see scripts/mkdocs_hooks.py.
172172
# YORE: EOL 3.9: Replace `**_dataclass_options` with `frozen=True, kw_only=True` within line.
173-
@dataclass(**_dataclass_options)
173+
@dataclass(**_dataclass_options) # type: ignore[call-overload]
174174
class CInputConfig:
175175
"""C handler configuration."""
176176

@@ -192,7 +192,7 @@ def from_data(cls, **data: Any) -> Self:
192192

193193

194194
# YORE: EOL 3.9: Replace `**_dataclass_options` with `frozen=True, kw_only=True` within line.
195-
@dataclass(**_dataclass_options)
195+
@dataclass(**_dataclass_options) # type: ignore[call-overload]
196196
class CConfig(CInputConfig): # type: ignore[override,unused-ignore]
197197
"""C handler configuration."""
198198

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,4 @@ def fixture_handler(plugin: MkdocstringsPlugin, ext_markdown: Markdown) -> CHand
8585
"""
8686
handler = plugin.handlers.get_handler("c")
8787
handler._update_env(ext_markdown, config=plugin.handlers._tool_config)
88-
return handler # type: ignore[return-value]
88+
return handler

tests/test_api.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,7 @@ def _fixture_inventory() -> Inventory:
100100
def test_exposed_objects(modulelevel_internal_objects: list[griffe.Object | griffe.Alias]) -> None:
101101
"""All public objects in the internal API are exposed under `mkdocstrings_handlers.c`."""
102102
not_exposed = [
103-
obj.path
104-
for obj in modulelevel_internal_objects
105-
if obj.name not in c.__all__ or not hasattr(c, obj.name)
103+
obj.path for obj in modulelevel_internal_objects if obj.name not in c.__all__ or not hasattr(c, obj.name)
106104
]
107105
assert not not_exposed, "Objects not exposed:\n" + "\n".join(sorted(not_exposed))
108106

@@ -161,11 +159,7 @@ def test_inventory_matches_api(
161159
public_api_paths.add("mkdocstrings_handlers")
162160
public_api_paths.add("mkdocstrings_handlers.c")
163161
for item in inventory.values():
164-
if (
165-
item.domain == "py"
166-
and "(" not in item.name
167-
and _module_or_child("mkdocstrings_handlers.c", item.name)
168-
):
162+
if item.domain == "py" and "(" not in item.name and _module_or_child("mkdocstrings_handlers.c", item.name):
169163
obj = loader.modules_collection[item.name]
170164
if obj.path not in public_api_paths and not any(path in public_api_paths for path in obj.aliases):
171165
not_in_api.append(item.name)

0 commit comments

Comments
 (0)