|
From: <aa-...@us...> - 2024-08-01 21:25:59
|
Revision: 9839
http://sourceforge.net/p/docutils/code/9839
Author: aa-turner
Date: 2024-08-01 21:25:56 +0000 (Thu, 01 Aug 2024)
Log Message:
-----------
Enable the flake8-comprehensions linter in Ruff
Modified Paths:
--------------
trunk/docutils/.ruff.toml
trunk/docutils/docutils/parsers/rst/directives/images.py
trunk/docutils/docutils/utils/__init__.py
trunk/docutils/docutils/utils/math/math2html.py
trunk/docutils/docutils/utils/smartquotes.py
trunk/docutils/test/test_viewlist.py
trunk/docutils/test/test_writers/test_latex2e.py
Modified: trunk/docutils/.ruff.toml
===================================================================
--- trunk/docutils/.ruff.toml 2024-08-01 21:23:58 UTC (rev 9838)
+++ trunk/docutils/.ruff.toml 2024-08-01 21:25:56 UTC (rev 9839)
@@ -5,6 +5,7 @@
[lint]
preview = true
select = [
+ "C4", # flake8-comprehensions
"E", # pycodestyle
"EXE", # flake8-executable
"DTZ", # flake8-datetimez
Modified: trunk/docutils/docutils/parsers/rst/directives/images.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/images.py 2024-08-01 21:23:58 UTC (rev 9838)
+++ trunk/docutils/docutils/parsers/rst/directives/images.py 2024-08-01 21:25:56 UTC (rev 9839)
@@ -81,7 +81,7 @@
if 'target' in self.options:
block = states.escape2null(
self.options['target']).splitlines()
- block = [line for line in block]
+ block = list(block)
target_type, data = self.state.parse_target(
block, self.block_text, self.lineno)
if target_type == 'refuri':
Modified: trunk/docutils/docutils/utils/__init__.py
===================================================================
--- trunk/docutils/docutils/utils/__init__.py 2024-08-01 21:23:58 UTC (rev 9838)
+++ trunk/docutils/docutils/utils/__init__.py 2024-08-01 21:25:56 UTC (rev 9839)
@@ -720,7 +720,7 @@
tag = tag.lower().replace('-', '_')
# split (except singletons, which mark the following tag as non-standard):
tag = re.sub(r'_([a-zA-Z0-9])_', r'_\1-', tag)
- subtags = [subtag for subtag in tag.split('_')]
+ subtags = list(tag.split('_'))
base_tag = (subtags.pop(0),)
# find all combinations of subtags
taglist = []
Modified: trunk/docutils/docutils/utils/math/math2html.py
===================================================================
--- trunk/docutils/docutils/utils/math/math2html.py 2024-08-01 21:23:58 UTC (rev 9838)
+++ trunk/docutils/docutils/utils/math/math2html.py 2024-08-01 21:25:56 UTC (rev 9839)
@@ -1316,7 +1316,7 @@
begin = None
def __init__(self) -> None:
- self.contents = list()
+ self.contents = []
def process(self) -> None:
"Process contents"
Modified: trunk/docutils/docutils/utils/smartquotes.py
===================================================================
--- trunk/docutils/docutils/utils/smartquotes.py 2024-08-01 21:23:58 UTC (rev 9838)
+++ trunk/docutils/docutils/utils/smartquotes.py 2024-08-01 21:25:56 UTC (rev 9839)
@@ -918,7 +918,7 @@
defaultlanguage = defaultlanguage.lower().replace('-', '_')
# split (except singletons, which mark the following tag as non-standard):
defaultlanguage = re.sub(r'_([a-zA-Z0-9])_', r'_\1-', defaultlanguage)
- _subtags = [subtag for subtag in defaultlanguage.split('_')]
+ _subtags = list(defaultlanguage.split('_'))
_basetag = _subtags.pop(0)
# find all combinations of subtags
for n in range(len(_subtags), 0, -1):
Modified: trunk/docutils/test/test_viewlist.py
===================================================================
--- trunk/docutils/test/test_viewlist.py 2024-08-01 21:23:58 UTC (rev 9838)
+++ trunk/docutils/test/test_viewlist.py 2024-08-01 21:25:56 UTC (rev 9839)
@@ -46,7 +46,7 @@
self.assertEqual(self.c, self.c_list)
self.assertEqual(len(self.a), len(self.a_list))
self.assertTrue('d' in self.a) # __contains__
- self.assertEqual([value for value in self.a], self.a_list)
+ self.assertEqual(list(self.a), self.a_list)
# get and set values
self.assertEqual(self.a[2], self.a_list[2])
a = self.a[:]
Modified: trunk/docutils/test/test_writers/test_latex2e.py
===================================================================
--- trunk/docutils/test/test_writers/test_latex2e.py 2024-08-01 21:23:58 UTC (rev 9838)
+++ trunk/docutils/test/test_writers/test_latex2e.py 2024-08-01 21:25:56 UTC (rev 9839)
@@ -121,24 +121,24 @@
\begin{document}
$titledata""")
-parts = dict(
-head_prefix=r"""\documentclass[a4paper]{article}
+parts = {
+'head_prefix': r"""\documentclass[a4paper]{article}
""",
-requirements=r"""\usepackage{ifthen}
+'requirements': r"""\usepackage{ifthen}
\usepackage[T1]{fontenc}
""",
-latex_preamble=r"""% PDF Standard Fonts
+'latex_preamble': r"""% PDF Standard Fonts
\usepackage{mathptmx} % Times
\usepackage[scaled=.90]{helvet}
\usepackage{courier}
""",
-longtable=r"""\usepackage{longtable,ltcaption,array}
+'longtable': r"""\usepackage{longtable,ltcaption,array}
\setlength{\extrarowheight}{2pt}
\newlength{\DUtablewidth} % internal use in tables
""",
-stylesheet='',
-fallbacks='',
-fallbacks_highlight=r"""
+'stylesheet': '',
+'fallbacks': '',
+'fallbacks_highlight': r"""
% basic code highlight:
\providecommand*\DUrolecomment[1]{\textcolor[rgb]{0.40,0.40,0.40}{#1}}
\providecommand*\DUroledeleted[1]{\textcolor[rgb]{0.40,0.40,0.40}{#1}}
@@ -154,7 +154,7 @@
\fi%
}
""",
-pdfsetup=r"""
+'pdfsetup': r"""
% hyperlinks:
\ifthenelse{\isundefined{\hypersetup}}{
\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
@@ -162,7 +162,7 @@
\urlstyle{same} % normal text font (alternatives: tt, rm, sf)
}{}
""",
-titledata='')
+'titledata': ''}
head = head_template.substitute(parts)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|