From 219f9ee60811d7906972a8223a0c147dd0d74e2e Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Fri, 22 Mar 2024 19:23:11 -0500 Subject: [PATCH] chore(mypy): docutils linting src/django_docutils/lib/roles/common.py:134: error: Too many arguments for "Text" [call-arg] src/django_docutils/lib/metadata/extract.py:57: error: Need more than 0 values to unpack (2 expected) [misc] src/django_docutils/lib/publisher.py:36: error: Need type annotation for "reader" [var-annotated] src/django_docutils/lib/publisher.py:48: error: Unused "type: ignore" comment [unused-ignore] src/django_docutils/lib/publisher.py:50: error: Unused "type: ignore" comment [unused-ignore] src/django_docutils/lib/publisher.py:124: error: Returning Any from function declared to return "document" [no-any-return] Found 6 errors in 3 files (checked 55 source files) --- src/django_docutils/lib/metadata/extract.py | 1 + src/django_docutils/lib/publisher.py | 8 ++++---- src/django_docutils/lib/roles/common.py | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/django_docutils/lib/metadata/extract.py b/src/django_docutils/lib/metadata/extract.py index 40dce804..08174cc6 100644 --- a/src/django_docutils/lib/metadata/extract.py +++ b/src/django_docutils/lib/metadata/extract.py @@ -54,6 +54,7 @@ def extract_metadata(document: nodes.document) -> dict[str, str]: continue if element.tagname == "field": # custom fields (e.g. summary) + assert len(element.children) == 2 name_elem, body_elem = element.children assert isinstance(name_elem, (nodes.Text, nodes.Element)) assert isinstance(body_elem, (nodes.Text, nodes.Element)) diff --git a/src/django_docutils/lib/publisher.py b/src/django_docutils/lib/publisher.py index 6ab89226..bee1dca9 100644 --- a/src/django_docutils/lib/publisher.py +++ b/src/django_docutils/lib/publisher.py @@ -33,7 +33,7 @@ def publish_parts_from_doctree( enable_exit_status: bool = False, ) -> dict[str, str]: """Render docutils doctree into docutils parts.""" - reader = Reader(parser_name="null") + reader = Reader(parser_name="null") # type:ignore pub = Publisher( reader, None, @@ -45,9 +45,9 @@ def publish_parts_from_doctree( if not writer and writer_name: pub.set_writer(writer_name) pub.process_programmatic_settings( - settings_spec, # type:ignore + settings_spec, settings_overrides, - config_section, # type:ignore + config_section, ) pub.set_destination(None, destination_path) pub.publish(enable_exit_status=enable_exit_status) @@ -121,7 +121,7 @@ def publish_doctree( register_django_docutils_directives() register_django_docutils_roles() - return docutils_publish_doctree( + return docutils_publish_doctree( # type:ignore source=force_bytes(source), settings_overrides=settings_overrides, ) diff --git a/src/django_docutils/lib/roles/common.py b/src/django_docutils/lib/roles/common.py index 8822a7b8..a9572359 100644 --- a/src/django_docutils/lib/roles/common.py +++ b/src/django_docutils/lib/roles/common.py @@ -130,7 +130,7 @@ def url_handler(target): if not has_explicit_title: title = utils.unescape(remote_title) - sn = innernodeclass(title, title) + sn = innernodeclass(title) rn = nodes.reference("", "", internal=True, refuri=url, classes=[name]) rn += sn return [rn], []