diff --git a/pyproject.toml b/pyproject.toml index cca732f6b..be86e48fc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -141,8 +141,17 @@ show_column_numbers = true show_error_context = true strict_optional = true warn_redundant_casts = true +warn_unused_configs = true warn_unused_ignores = true disallow_any_generics = true +extra_checks = true +enable_error_code = [ + "type-arg", + "redundant-self", + "truthy-iterable", + "ignore-without-code", + "unused-awaitable", +] [[tool.mypy.overrides]] module = [ diff --git a/sphinx/domains/__init__.py b/sphinx/domains/__init__.py index 7c1122038..153e75111 100644 --- a/sphinx/domains/__init__.py +++ b/sphinx/domains/__init__.py @@ -93,7 +93,7 @@ class Index(ABC): shortname: str | None = None def __init__(self, domain: Domain) -> None: - if self.name is None or self.localname is None: + if not self.name or self.localname is None: raise SphinxError('Index subclass %s has no valid name or localname' % self.__class__.__name__) self.domain = domain diff --git a/sphinx/highlighting.py b/sphinx/highlighting.py index 7e0d94a07..b4390ebc9 100644 --- a/sphinx/highlighting.py +++ b/sphinx/highlighting.py @@ -104,8 +104,8 @@ class PygmentsBridge: self.formatter = self.latex_formatter self.formatter_args['commandprefix'] = 'PYG' - def get_style(self, stylename: str) -> Style: - if stylename is None or stylename == 'sphinx': + def get_style(self, stylename: str) -> type[Style]: + if not stylename or stylename == 'sphinx': return SphinxStyle elif stylename == 'none': return NoneStyle diff --git a/sphinx/transforms/post_transforms/images.py b/sphinx/transforms/post_transforms/images.py index 561dcfc38..f98514f9c 100644 --- a/sphinx/transforms/post_transforms/images.py +++ b/sphinx/transforms/post_transforms/images.py @@ -47,7 +47,7 @@ class ImageDownloader(BaseImageConverter): default_priority = 100 def match(self, node: nodes.image) -> bool: - if self.app.builder.supported_image_types == []: + if not self.app.builder.supported_image_types: return False if self.app.builder.supported_remote_images: return False @@ -117,7 +117,7 @@ class DataURIExtractor(BaseImageConverter): default_priority = 150 def match(self, node: nodes.image) -> bool: - if self.app.builder.supported_remote_images == []: + if not self.app.builder.supported_remote_images: return False if self.app.builder.supported_data_uri_images is True: return False diff --git a/sphinx/util/nodes.py b/sphinx/util/nodes.py index b68b7fdd4..f9ce975f9 100644 --- a/sphinx/util/nodes.py +++ b/sphinx/util/nodes.py @@ -220,7 +220,7 @@ def is_translatable(node: Node) -> bool: return False # orphan # XXX ignore all metadata (== docinfo) - if isinstance(node, nodes.field_name) and node.children[0] == 'orphan': + if isinstance(node, nodes.field_name) and (node.children[0] == 'orphan'): logger.debug('[i18n] SKIP %r because orphan node: %s', get_full_module_name(node), repr_domxml(node)) return False