This commit is contained in:
ton
2024-10-07 10:13:40 +07:00
parent aa1631742f
commit 3a7d696db6
9729 changed files with 1832837 additions and 161742 deletions

View File

@@ -2,16 +2,17 @@
Implements the Distutils 'check' command.
"""
import contextlib
from ..core import Command
from ..errors import DistutilsSetupError
with contextlib.suppress(ImportError):
import docutils.utils
import docutils.parsers.rst
import docutils.frontend
import docutils.nodes
import docutils.parsers.rst
import docutils.utils
class SilentReporter(docutils.utils.Reporter):
def __init__(
@@ -20,7 +21,7 @@ with contextlib.suppress(ImportError):
report_level,
halt_level,
stream=None,
debug=0,
debug=False,
encoding='ascii',
error_handler='replace',
):
@@ -32,7 +33,7 @@ with contextlib.suppress(ImportError):
def system_message(self, level, message, *children, **kwargs):
self.messages.append((level, message, children, kwargs))
return docutils.nodes.system_message(
message, level=level, type=self.levels[level], *children, **kwargs
message, *children, level=level, type=self.levels[level], **kwargs
)
@@ -57,9 +58,9 @@ class check(Command):
def initialize_options(self):
"""Sets default values for options."""
self.restructuredtext = 0
self.restructuredtext = False
self.metadata = 1
self.strict = 0
self.strict = False
self._warnings = 0
def finalize_options(self):
@@ -99,13 +100,12 @@ class check(Command):
"""
metadata = self.distribution.metadata
missing = []
for attr in 'name', 'version':
if not getattr(metadata, attr, None):
missing.append(attr)
missing = [
attr for attr in ('name', 'version') if not getattr(metadata, attr, None)
]
if missing:
self.warn("missing required meta-data: %s" % ', '.join(missing))
self.warn("missing required meta-data: {}".format(', '.join(missing)))
def check_restructuredtext(self):
"""Checks if the long string fields are reST-compliant."""
@@ -115,7 +115,7 @@ class check(Command):
if line is None:
warning = warning[1]
else:
warning = '{} (line {})'.format(warning[1], line)
warning = f'{warning[1]} (line {line})'
self.warn(warning)
def _check_rst_data(self, data):
@@ -144,8 +144,11 @@ class check(Command):
try:
parser.parse(data, document)
except AttributeError as e:
reporter.messages.append(
(-1, 'Could not finish the parsing: %s.' % e, '', {})
)
reporter.messages.append((
-1,
f'Could not finish the parsing: {e}.',
'',
{},
))
return reporter.messages