|
From: <aa-...@us...> - 2024-07-31 08:35:50
|
Revision: 9795
http://sourceforge.net/p/docutils/code/9795
Author: aa-turner
Date: 2024-07-31 08:35:47 +0000 (Wed, 31 Jul 2024)
Log Message:
-----------
Add an initial configuration file for Ruff
This reflects the current flake8 settings, save diagnostics
that Ruff does not implement. Ruff's detection of unused variables
seems to be greater than flake8's, so also fix several instances
and add some more files to the per-file ignore list.
Modified Paths:
--------------
trunk/docutils/docutils/core.py
trunk/docutils/docutils/parsers/rst/directives/tables.py
trunk/docutils/docutils/parsers/rst/languages/ka.py
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/docutils/writers/manpage.py
trunk/docutils/test/test_dependencies.py
trunk/docutils/test/test_parsers/test_rst/test_TableParser.py
trunk/docutils/test/test_statemachine.py
trunk/docutils/tools/test/test_buildhtml.py
Added Paths:
-----------
trunk/docutils/.ruff.toml
Added: trunk/docutils/.ruff.toml
===================================================================
--- trunk/docutils/.ruff.toml (rev 0)
+++ trunk/docutils/.ruff.toml 2024-07-31 08:35:47 UTC (rev 9795)
@@ -0,0 +1,143 @@
+target-version = "py39" # Pin Ruff to Python 3.9
+line-length = 88
+output-format = "full"
+
+[lint]
+preview = true
+select = [
+ "E", # pycodestyle
+ "F", # pyflakes
+ "W", # pycodestyle
+]
+ignore = [
+ "E226", # missing whitespace around arithmetic operator
+ "E228", # missing whitespace around modulo operator
+ # not generally frowned on by PEP 8:
+ # "If operators with different priorities are used, consider adding
+ # whitespace around the operators with the lowest priority(ies).
+ # Use your own judgment; …"
+]
+
+[lint.per-file-ignores]
+# class definitions with "…: pass" on one line
+"docutils/__init__.py" = [
+ "E302",
+ "E701",
+]
+"docutils/nodes.py" = [
+ "E302",
+ "E701",
+]
+"docutils/io.py" = [
+ "E302",
+ "E701",
+]
+"docutils/statemachine.py" = [
+ "E302",
+ "E701",
+ "F841",
+]
+"docutils/utils/__init__.py" = [
+ "E302",
+ "E701",
+]
+
+# complex regexp definitions
+"docutils/parsers/rst/states.py" = [
+ "E302",
+ "E701",
+ "F841",
+]
+# deprecated module, will be removed
+"docutils/utils/error_reporting.py" = [
+ "E261",
+]
+
+# module with 3rd-party origin
+"docutils/utils/math/math2html.py" = [
+ "E241",
+ "E501",
+ "E731",
+]
+
+# generated auxiliary files
+"docutils/utils/math/tex2unichar.py" = [
+ "E262",
+ "E501",
+]
+"docutils/utils/math/mathalphabet2unichar.py" = [
+ "E501",
+]
+
+# allow aligning values in data-collections
+"docutils/utils/smartquotes.py" = [
+ "E241",
+]
+"docutils/utils/roman.py" = [
+ "E241",
+ "E701",
+]
+"docutils/utils/math/latex2mathml.py" = [
+ "E221",
+ "E241",
+ "E272",
+ "E501",
+ "E701",
+]
+"docutils/writers/xetex/__init__.py" = [
+ "E241",
+]
+
+# also allow '##' to mark deactivated code:
+"docutils/writers/latex2e/__init__.py" = [
+ "E241",
+ "E266",
+]
+
+# ignore unused variables
+"docutils/parsers/rst/directives/misc.py" = [
+ "F841",
+]
+"docutils/writers/odf_odt/__init__.py" = [
+ "F841",
+]
+
+# included configuration files referencing externally defined variables
+"test/functional/tests/*" = [
+ "F821",
+]
+
+# deprecated module, will be removed
+"test/test_error_reporting.py" = [
+ "E261",
+]
+
+# Lists with multi-line test output samples
+# may contain long lines (E501)
+# and are not indented (E122, E124, E128)
+"test/test_parsers/*" = [
+ "E501",
+]
+"test/test_publisher.py" = [
+ "E501",
+]
+"test/test_readers/test_pep/*" = [
+ "E501",
+]
+"test/test_transforms/*" = [
+ "E501",
+]
+"test/test_writers/*" = [
+ "E501",
+]
+
+# test output contains trailing whitespace, long lines, operator at end
+"test/test_writers/test_manpage.py" = [
+ "W291",
+ "E501",
+]
+
+# ignore long line in string templates
+"tools/dev/generate_punctuation_chars.py" = [
+ "E501",
+]
Modified: trunk/docutils/docutils/core.py
===================================================================
--- trunk/docutils/docutils/core.py 2024-07-31 07:45:30 UTC (rev 9794)
+++ trunk/docutils/docutils/core.py 2024-07-31 08:35:47 UTC (rev 9795)
@@ -438,7 +438,7 @@
# The "*_name" arguments are deprecated.
_name_arg_warning(reader_name, parser_name, writer_name)
# The default is set in publish_programmatically().
- output, publisher = publish_programmatically(
+ output, _publisher = publish_programmatically(
source_class=io.FileInput, source=source, source_path=source_path,
destination_class=io.FileOutput,
destination=destination, destination_path=destination_path,
@@ -480,7 +480,7 @@
# The "*_name" arguments are deprecated.
_name_arg_warning(reader_name, parser_name, writer_name)
# The default is set in publish_programmatically().
- output, publisher = publish_programmatically(
+ output, _publisher = publish_programmatically(
source_class=io.StringInput, source=source, source_path=source_path,
destination_class=io.StringOutput,
destination=None, destination_path=destination_path,
@@ -521,7 +521,7 @@
# The "*_name" arguments are deprecated.
_name_arg_warning(reader_name, parser_name, writer_name)
# The default is set in publish_programmatically().
- output, publisher = publish_programmatically(
+ _output, publisher = publish_programmatically(
source=source, source_path=source_path, source_class=source_class,
destination_class=io.StringOutput,
destination=None, destination_path=destination_path,
Modified: trunk/docutils/docutils/parsers/rst/directives/tables.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/tables.py 2024-07-31 07:45:30 UTC (rev 9794)
+++ trunk/docutils/docutils/parsers/rst/directives/tables.py 2024-07-31 08:35:47 UTC (rev 9795)
@@ -430,7 +430,7 @@
node = nodes.Element() # anonymous container for parsing
self.state.nested_parse(self.content, self.content_offset, node)
try:
- num_cols, col_widths = self.check_list_content(node)
+ _num_cols, col_widths = self.check_list_content(node)
table_data = [[item.children for item in row_list[0]]
for row_list in node[0]]
header_rows = self.options.get('header-rows', 0)
Modified: trunk/docutils/docutils/parsers/rst/languages/ka.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/languages/ka.py 2024-07-31 07:45:30 UTC (rev 9794)
+++ trunk/docutils/docutils/parsers/rst/languages/ka.py 2024-07-31 08:35:47 UTC (rev 9795)
@@ -44,7 +44,6 @@
'ნაგულისხმევი-როლი': 'default-role',
'სათაური': 'title',
'განყ-ნომერი': 'sectnum',
- 'განყ-ნომერი': 'sectnum',
'საფრთხე': 'danger',
'ფრთხილად': 'caution',
'შეცდომა': 'error',
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2024-07-31 07:45:30 UTC (rev 9794)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2024-07-31 08:35:47 UTC (rev 9795)
@@ -1202,10 +1202,10 @@
self.literal_block_env = ''
self.literal_block_options = ''
if settings.literal_block_env:
- (none,
+ (_none,
self.literal_block_env,
self.literal_block_options,
- none) = re.split(r'(\w+)(.*)', settings.literal_block_env)
+ _none) = re.split(r'(\w+)(.*)', settings.literal_block_env)
elif settings.use_verbatim_when_possible:
self.literal_block_env = 'verbatim'
Modified: trunk/docutils/docutils/writers/manpage.py
===================================================================
--- trunk/docutils/docutils/writers/manpage.py 2024-07-31 07:45:30 UTC (rev 9794)
+++ trunk/docutils/docutils/writers/manpage.py 2024-07-31 08:35:47 UTC (rev 9795)
@@ -747,7 +747,7 @@
pass
def visit_footnote(self, node):
- num, text = node.astext().split(None, 1)
+ num, _text = node.astext().split(maxsplit=1)
num = num.strip()
self.body.append('.IP [%s] 5\n' % self.deunicode(num))
Modified: trunk/docutils/test/test_dependencies.py
===================================================================
--- trunk/docutils/test/test_dependencies.py 2024-07-31 07:45:30 UTC (rev 9794)
+++ trunk/docutils/test/test_dependencies.py 2024-07-31 08:35:47 UTC (rev 9795)
@@ -76,7 +76,7 @@
if PIL and os.path.exists('../docs/user/rst/images/'):
keys += ['figure-image']
expected = [paths[key] for key in keys]
- record, output = self.get_record(writer='xml')
+ record, _output = self.get_record(writer='xml')
# the order of the files is arbitrary
self.assertEqual(sorted(expected), sorted(record))
@@ -123,23 +123,23 @@
'stylesheet': None}
settings.update(latex_settings_overwrites)
settings['embed_stylesheet'] = False
- record, output = self.get_record(writer='html',
- settings_overrides=settings)
+ record, _output = self.get_record(writer='html',
+ settings_overrides=settings)
self.assertTrue(stylesheet not in record,
f'{stylesheet!r} should not be in {record!r}')
- record, output = self.get_record(writer='latex',
- settings_overrides=settings)
+ record, _output = self.get_record(writer='latex',
+ settings_overrides=settings)
self.assertTrue(stylesheet not in record,
f'{stylesheet!r} should not be in {record!r}')
settings['embed_stylesheet'] = True
- record, output = self.get_record(writer='html',
- settings_overrides=settings)
+ record, _output = self.get_record(writer='html',
+ settings_overrides=settings)
self.assertTrue(stylesheet in record,
f'{stylesheet!r} should be in {record!r}')
settings['embed_stylesheet'] = True
- record, output = self.get_record(writer='latex',
- settings_overrides=settings)
+ record, _output = self.get_record(writer='latex',
+ settings_overrides=settings)
self.assertTrue(stylesheet in record,
f'{stylesheet!r} should be in {record!r}')
Modified: trunk/docutils/test/test_parsers/test_rst/test_TableParser.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_TableParser.py 2024-07-31 07:45:30 UTC (rev 9794)
+++ trunk/docutils/test/test_parsers/test_rst/test_TableParser.py 2024-07-31 08:35:47 UTC (rev 9795)
@@ -25,7 +25,7 @@
parser = tableparser.GridTableParser()
for name, cases in totest.items():
for casenum, case in enumerate(cases):
- case_input, case_table, case_expected = case
+ case_input, case_table, _case_expected = case
lines_input = StringList(string2lines(case_input), 'test data')
parser.setup(lines_input)
try:
@@ -40,7 +40,7 @@
parser = tableparser.GridTableParser()
for name, cases in totest.items():
for casenum, case in enumerate(cases):
- case_input, case_table, case_expected = case
+ case_input, _case_table, case_expected = case
lines_input = StringList(string2lines(case_input), 'test data')
with self.subTest(id=f'totest[{name!r}][{casenum}]'):
try:
Modified: trunk/docutils/test/test_statemachine.py
===================================================================
--- trunk/docutils/test/test_statemachine.py 2024-07-31 07:45:30 UTC (rev 9794)
+++ trunk/docutils/test/test_statemachine.py 2024-07-31 08:35:47 UTC (rev 9795)
@@ -102,7 +102,7 @@
return [match.string], next_state, ['text%s' % self.level]
def literalblock(self):
- indented, indent, offset, good = self.state_machine.get_indented()
+ _indented, indent, _offset, _good = self.state_machine.get_indented()
if self.debug:
print('literalblock%s(%s)' % (self.level, indent), file=sys.stderr)
return ['literalblock%s(%s)' % (self.level, indent)]
Modified: trunk/docutils/tools/test/test_buildhtml.py
===================================================================
--- trunk/docutils/tools/test/test_buildhtml.py 2024-07-31 07:45:30 UTC (rev 9794)
+++ trunk/docutils/tools/test/test_buildhtml.py 2024-07-31 08:35:47 UTC (rev 9795)
@@ -34,7 +34,9 @@
BUILDHTML_PATH = TOOLS_ROOT / 'buildhtml.py'
-def process_and_return_filelist(options: list[str]) -> tuple[list[str], list[str]]:
+def process_and_return_filelist(
+ options: list[str],
+) -> tuple[list[str], list[str]]:
dirs = []
files = []
ret = subprocess.run(
@@ -80,7 +82,7 @@
def test_1(self):
opts = ["--dry-run", str(self.root)]
- dirs, files = process_and_return_filelist(opts)
+ _dirs, files = process_and_return_filelist(opts)
self.assertEqual(files.count("one.txt"), 4)
def test_local(self):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|