Skip to content

Commit 43bcbfa

Browse files
committed
ci: Update typing from mypy to ty
1 parent 616b8f3 commit 43bcbfa

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

src/griffe_pydantic/_internal/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@
2929

3030

3131
def _model_fields(cls: Class) -> dict[str, Attribute]:
32-
return {name: attr for name, attr in cls.all_members.items() if "pydantic-field" in attr.labels} # type: ignore[misc]
32+
return {name: attr for name, attr in cls.all_members.items() if "pydantic-field" in attr.labels} # ty: ignore[invalid-return-type]
3333

3434

3535
def _model_validators(cls: Class) -> dict[str, Function]:
36-
return {name: func for name, func in cls.all_members.items() if "pydantic-validator" in func.labels} # type: ignore[misc]
36+
return {name: func for name, func in cls.all_members.items() if "pydantic-validator" in func.labels} # ty: ignore[invalid-return-type]
3737

3838

3939
def _json_schema(model: type[BaseModel]) -> str:

src/griffe_pydantic/_internal/dynamic.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ def _process_class(obj: type, cls: Class, *, processed: set[str], schema: bool =
5757
common._process_class(cls)
5858
if schema:
5959
try:
60-
cls.extra[common._self_namespace]["schema"] = common._json_schema(obj)
60+
cls.extra[common._self_namespace]["schema"] = common._json_schema(obj) # ty: ignore[invalid-argument-type]
6161
except Exception as exc: # noqa: BLE001
6262
# Schema generation can fail and raise Pydantic errors.
6363
_logger.debug("Failed to generate schema for %s: %s", cls.path, exc)
6464
for member in cls.all_members.values():
6565
kind = member.kind
6666
if kind is Kind.ATTRIBUTE:
67-
_process_attribute(getattr(obj, member.name), member, cls, processed=processed) # type: ignore[arg-type]
67+
_process_attribute(getattr(obj, member.name), member, cls, processed=processed) # ty: ignore[invalid-argument-type]
6868
elif kind is Kind.FUNCTION:
69-
_process_function(getattr(obj, member.name), member, cls, processed=processed) # type: ignore[arg-type]
69+
_process_function(getattr(obj, member.name), member, cls, processed=processed) # ty: ignore[invalid-argument-type]

src/griffe_pydantic/_internal/static.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def _process_attribute(attr: Attribute, cls: Class, *, processed: set[str]) -> N
152152
# Populate docstring from the field's `description` argument.
153153
if not attr.docstring and (docstring := kwargs.get("description")):
154154
try:
155-
attr.docstring = Docstring(ast.literal_eval(docstring), parent=attr) # type: ignore[arg-type]
155+
attr.docstring = Docstring(ast.literal_eval(docstring), parent=attr) # ty: ignore[invalid-argument-type]
156156
except ValueError:
157157
_logger.debug(f"Could not parse description of field '{attr.path}' as literal, skipping")
158158

@@ -205,11 +205,11 @@ def _process_class(cls: Class, *, processed: set[str], schema: bool = False) ->
205205
for member in cls.all_members.values():
206206
kind = member.kind
207207
if kind is Kind.ATTRIBUTE:
208-
_process_attribute(member, cls, processed=processed) # type: ignore[arg-type]
208+
_process_attribute(member, cls, processed=processed) # ty: ignore[invalid-argument-type]
209209
elif kind is Kind.FUNCTION:
210-
_process_function(member, cls, processed=processed) # type: ignore[arg-type]
210+
_process_function(member, cls, processed=processed) # ty: ignore[invalid-argument-type]
211211
elif kind is Kind.CLASS:
212-
_process_class(member, processed=processed, schema=schema) # type: ignore[arg-type]
212+
_process_class(member, processed=processed, schema=schema) # ty: ignore[invalid-argument-type]
213213

214214

215215
def _process_module(

tests/conftest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
from pathlib import Path
1515

1616
from mkdocs import config
17-
from mkdocstrings_handlers.python.handler import PythonHandler
17+
from mkdocstrings_handlers.python import PythonHandler
1818

1919

2020
@pytest.fixture(name="mkdocs_conf")
2121
def fixture_mkdocs_conf(request: pytest.FixtureRequest, tmp_path: Path) -> Iterator[config.Config]:
2222
"""Yield a MkDocs configuration object."""
2323
conf = MkDocsConfig()
2424
while hasattr(request, "_parent_request") and hasattr(request._parent_request, "_parent_request"):
25-
request = request._parent_request
25+
request = request._parent_request # ty: ignore[invalid-assignment]
2626

2727
conf_dict = {
2828
"site_name": "foo",
@@ -32,7 +32,7 @@ def fixture_mkdocs_conf(request: pytest.FixtureRequest, tmp_path: Path) -> Itera
3232
**getattr(request, "param", {}),
3333
}
3434
# Re-create it manually as a workaround for https://github.com/mkdocs/mkdocs/issues/2289
35-
mdx_configs: dict[str, Any] = dict(ChainMap(*conf_dict.get("markdown_extensions", [])))
35+
mdx_configs: dict[str, Any] = dict(ChainMap(*conf_dict.get("markdown_extensions", []))) # ty: ignore[invalid-argument-type]
3636

3737
conf.load_dict(conf_dict)
3838
assert conf.validate() == ([], [])
@@ -49,7 +49,7 @@ def fixture_mkdocs_conf(request: pytest.FixtureRequest, tmp_path: Path) -> Itera
4949
@pytest.fixture(name="python_handler")
5050
def fixture_python_handler(mkdocs_conf: MkDocsConfig) -> PythonHandler:
5151
"""Return a PythonHandler instance."""
52-
handlers = mkdocs_conf.plugins["mkdocstrings"].handlers # type: ignore[attr-defined]
52+
handlers = mkdocs_conf.plugins["mkdocstrings"].handlers # ty: ignore[possibly-missing-attribute]
5353
handler = handlers.get_handler("python")
5454
handler._update_env(md=Markdown(extensions=["toc"]))
5555
handler.env.filters["convert_markdown"] = lambda *args, **kwargs: str(args) + str(kwargs)

tests/test_extension.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from griffe_pydantic._internal.extension import PydanticExtension
1212

1313
if TYPE_CHECKING:
14-
from mkdocstrings_handlers.python.handler import PythonHandler
14+
from mkdocstrings_handlers.python import PythonHandler
1515

1616

1717
code = """

0 commit comments

Comments
 (0)