Skip to content

Commit 92e60b3

Browse files
committed
Fix PGH003 (type: ignore comment must have parameters)
1 parent e2ff04e commit 92e60b3

62 files changed

Lines changed: 250 additions & 207 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pyproject.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,6 @@ ignore = [
208208
"NPY", # numpy is not used in Sphinx
209209
# pandas-vet
210210
"PD", # pandas is not used in Sphinx
211-
# pygrep-hooks
212-
"PGH003",
213211
# flake8-pie
214212
"PIE790", # unnecessary 'pass' statement
215213
# pylint

sphinx/addnodes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class document(nodes.document):
4242

4343
def set_id(self, node: Element, msgnode: Element | None = None,
4444
suggested_prefix: str = '') -> str:
45-
return super().set_id(node, msgnode, suggested_prefix) # type: ignore
45+
return super().set_id(node, msgnode, suggested_prefix) # type: ignore[call-arg]
4646

4747

4848
class translatable(nodes.Node):

sphinx/application.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
from sphinx.theming import Theme
3939
from sphinx.util import docutils, logging
4040
from sphinx.util.build_phase import BuildPhase
41-
from sphinx.util.console import bold # type: ignore
41+
from sphinx.util.console import bold # type: ignore[attr-defined]
4242
from sphinx.util.display import progress_message
4343
from sphinx.util.i18n import CatalogRepository
4444
from sphinx.util.logging import prefixed_warnings

sphinx/builders/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from sphinx.locale import __
2121
from sphinx.util import UnicodeDecodeErrorHandler, get_filetype, import_object, logging, rst
2222
from sphinx.util.build_phase import BuildPhase
23-
from sphinx.util.console import bold # type: ignore
23+
from sphinx.util.console import bold # type: ignore[attr-defined]
2424
from sphinx.util.display import progress_message, status_iterator
2525
from sphinx.util.docutils import sphinx_domains
2626
from sphinx.util.i18n import CatalogInfo, CatalogRepository, docname_to_domain
@@ -490,7 +490,8 @@ def read_doc(self, docname: str, *, _cache: bool = True) -> None:
490490
publisher.settings.record_dependencies = DependencyList()
491491
with sphinx_domains(self.env), rst.default_role(docname, self.config.default_role):
492492
# set up error_handler for the target document
493-
codecs.register_error('sphinx', UnicodeDecodeErrorHandler(docname)) # type: ignore
493+
codecs.register_error('sphinx',
494+
UnicodeDecodeErrorHandler(docname)) # type: ignore[arg-type]
494495

495496
publisher.set_source(source_path=filename)
496497
publisher.publish()

sphinx/builders/changes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from sphinx.locale import _, __
1414
from sphinx.theming import HTMLThemeFactory
1515
from sphinx.util import logging
16-
from sphinx.util.console import bold # type: ignore
16+
from sphinx.util.console import bold # type: ignore[attr-defined]
1717
from sphinx.util.fileutil import copy_asset_file
1818
from sphinx.util.osutil import ensuredir, os_path
1919

sphinx/builders/epub3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ def convert_epub_css_files(app: Sphinx, config: Config) -> None:
251251
logger.warning(__('invalid css_file: %r, ignored'), entry)
252252
continue
253253

254-
config.epub_css_files = epub_css_files # type: ignore
254+
config.epub_css_files = epub_css_files # type: ignore[attr-defined]
255255

256256

257257
def setup(app: Sphinx) -> dict[str, Any]:

sphinx/builders/gettext.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from sphinx.errors import ThemeError
2020
from sphinx.locale import __
2121
from sphinx.util import logging
22-
from sphinx.util.console import bold # type: ignore
22+
from sphinx.util.console import bold # type: ignore[attr-defined]
2323
from sphinx.util.display import status_iterator
2424
from sphinx.util.i18n import CatalogInfo, docname_to_domain
2525
from sphinx.util.index_entries import split_index_msg
@@ -153,7 +153,7 @@ def write_doc(self, docname: str, doctree: nodes.document) -> None:
153153

154154
for toctree in self.env.tocs[docname].findall(addnodes.toctree):
155155
for node, msg in extract_messages(toctree):
156-
node.uid = '' # type: ignore # Hack UUID model
156+
node.uid = '' # type: ignore[attr-defined] # Hack UUID model
157157
catalog.add(msg, node)
158158

159159
for node, msg in extract_messages(doctree):

sphinx/builders/html/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def __init__(
134134
if tags:
135135
self.tags_hash = get_stable_hash(sorted(tags))
136136

137-
def __eq__(self, other: BuildInfo) -> bool: # type: ignore
137+
def __eq__(self, other: BuildInfo) -> bool: # type: ignore[override]
138138
return (self.config_hash == other.config_hash and
139139
self.tags_hash == other.tags_hash)
140140

@@ -1189,7 +1189,7 @@ def convert_html_css_files(app: Sphinx, config: Config) -> None:
11891189
logger.warning(__('invalid css_file: %r, ignored'), entry)
11901190
continue
11911191

1192-
config.html_css_files = html_css_files # type: ignore
1192+
config.html_css_files = html_css_files # type: ignore[attr-defined]
11931193

11941194

11951195
def convert_html_js_files(app: Sphinx, config: Config) -> None:
@@ -1206,7 +1206,7 @@ def convert_html_js_files(app: Sphinx, config: Config) -> None:
12061206
logger.warning(__('invalid js_file: %r, ignored'), entry)
12071207
continue
12081208

1209-
config.html_js_files = html_js_files # type: ignore
1209+
config.html_js_files = html_js_files # type: ignore[attr-defined]
12101210

12111211

12121212
def setup_resource_paths(app: Sphinx, pagename: str, templatename: str,
@@ -1229,7 +1229,7 @@ def validate_math_renderer(app: Sphinx) -> None:
12291229
if app.builder.format != 'html':
12301230
return
12311231

1232-
name = app.builder.math_renderer_name # type: ignore
1232+
name = app.builder.math_renderer_name # type: ignore[attr-defined]
12331233
if name is None:
12341234
raise ConfigError(__('Many math_renderers are registered. '
12351235
'But no math_renderer is selected.'))
@@ -1269,7 +1269,7 @@ def validate_html_logo(app: Sphinx, config: Config) -> None:
12691269
not path.isfile(path.join(app.confdir, config.html_logo)) and
12701270
not isurl(config.html_logo)):
12711271
logger.warning(__('logo file %r does not exist'), config.html_logo)
1272-
config.html_logo = None # type: ignore
1272+
config.html_logo = None # type: ignore[attr-defined]
12731273

12741274

12751275
def validate_html_favicon(app: Sphinx, config: Config) -> None:
@@ -1278,7 +1278,7 @@ def validate_html_favicon(app: Sphinx, config: Config) -> None:
12781278
not path.isfile(path.join(app.confdir, config.html_favicon)) and
12791279
not isurl(config.html_favicon)):
12801280
logger.warning(__('favicon file %r does not exist'), config.html_favicon)
1281-
config.html_favicon = None # type: ignore
1281+
config.html_favicon = None # type: ignore[attr-defined]
12821282

12831283

12841284
def error_on_html_4(_app: Sphinx, config: Config) -> None:

sphinx/builders/latex/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from sphinx.errors import NoUri, SphinxError
2323
from sphinx.locale import _, __
2424
from sphinx.util import logging, texescape
25-
from sphinx.util.console import bold, darkgreen # type: ignore
25+
from sphinx.util.console import bold, darkgreen # type: ignore[attr-defined]
2626
from sphinx.util.display import progress_message, status_iterator
2727
from sphinx.util.docutils import SphinxFileOutput, new_document
2828
from sphinx.util.fileutil import copy_asset_file
@@ -156,7 +156,7 @@ def init_document_data(self) -> None:
156156
logger.warning(__('"latex_documents" config value references unknown '
157157
'document %s'), docname)
158158
continue
159-
self.document_data.append(entry) # type: ignore
159+
self.document_data.append(entry) # type: ignore[arg-type]
160160
if docname.endswith(SEP + 'index'):
161161
docname = docname[:-5]
162162
self.titles.append((docname, entry[2]))

sphinx/builders/linkcheck.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@
2222
from sphinx.locale import __
2323
from sphinx.transforms.post_transforms import SphinxPostTransform
2424
from sphinx.util import encode_uri, logging, requests
25-
from sphinx.util.console import darkgray, darkgreen, purple, red, turquoise # type: ignore
25+
from sphinx.util.console import ( # type: ignore[attr-defined]
26+
darkgray,
27+
darkgreen,
28+
purple,
29+
red,
30+
turquoise,
31+
)
2632
from sphinx.util.nodes import get_node_line
2733

2834
if TYPE_CHECKING:

0 commit comments

Comments
 (0)