|
From: <mi...@us...> - 2022-03-05 23:27:33
|
Revision: 9027
http://sourceforge.net/p/docutils/code/9027
Author: milde
Date: 2022-03-05 23:27:30 +0000 (Sat, 05 Mar 2022)
Log Message:
-----------
Fix imports.
flake8 rules
E401: multiple imports on one line
E402: module level import not at top of file
Modified Paths:
--------------
trunk/docutils/docutils/__init__.py
trunk/docutils/docutils/utils/smartquotes.py
trunk/docutils/docutils/writers/_html_base.py
trunk/docutils/test/alltests.py
trunk/docutils/test/functional/tests/standalone_rst_s5_html_1.py
trunk/docutils/test/test_error_reporting.py
trunk/docutils/test/test_language.py
trunk/docutils/tox.ini
Modified: trunk/docutils/docutils/__init__.py
===================================================================
--- trunk/docutils/docutils/__init__.py 2022-03-04 15:57:13 UTC (rev 9026)
+++ trunk/docutils/docutils/__init__.py 2022-03-05 23:27:30 UTC (rev 9027)
@@ -50,6 +50,8 @@
- writers: Format-specific output translators.
"""
+from collections import namedtuple
+
__docformat__ = 'reStructuredText'
__version__ = '0.19b.dev'
@@ -69,9 +71,6 @@
"""
-from collections import namedtuple
-
-
class VersionInfo(namedtuple('VersionInfo',
'major minor micro releaselevel serial release')):
Modified: trunk/docutils/docutils/utils/smartquotes.py
===================================================================
--- trunk/docutils/docutils/utils/smartquotes.py 2022-03-04 15:57:13 UTC (rev 9026)
+++ trunk/docutils/docutils/utils/smartquotes.py 2022-03-05 23:27:30 UTC (rev 9027)
@@ -259,7 +259,7 @@
Version History
===============
-1.8.2 2022-01-27
+1.9 2022-03-04
- Code cleanup. Require Python 3.
1.8.1 2017-10-25
@@ -317,6 +317,10 @@
- Initial release
"""
+import re
+import sys
+
+
options = r"""
Options
=======
@@ -379,12 +383,6 @@
"""
-default_smartypants_attr = "1"
-
-
-import re, sys
-
-
class smartchars:
"""Smart quotes and dashes"""
@@ -502,11 +500,13 @@
self.opquote, self.cpquote, self.osquote, self.csquote = '""\'\''
+default_smartypants_attr = '1'
+
+
def smartyPants(text, attr=default_smartypants_attr, language='en'):
"""Main function for "traditional" use."""
- return "".join(t for t in educate_tokens(tokenize(text),
- attr, language))
+ return "".join(t for t in educate_tokens(tokenize(text), attr, language))
def educate_tokens(text_tokens, attr=default_smartypants_attr, language='en'):
@@ -534,36 +534,36 @@
do_stupefy = False
# if attr == "0": # pass tokens unchanged (see below).
- if attr == "1": # Do everything, turn all options on.
+ if attr == '1': # Do everything, turn all options on.
do_quotes = True
do_backticks = True
do_dashes = 1
do_ellipses = True
- elif attr == "2":
+ elif attr == '2':
# Do everything, turn all options on, use old school dash shorthand.
do_quotes = True
do_backticks = True
do_dashes = 2
do_ellipses = True
- elif attr == "3":
+ elif attr == '3':
# Do everything, use inverted old school dash shorthand.
do_quotes = True
do_backticks = True
do_dashes = 3
do_ellipses = True
- elif attr == "-1": # Special "stupefy" mode.
+ elif attr == '-1': # Special "stupefy" mode.
do_stupefy = True
else:
- if "q" in attr: do_quotes = True
- if "b" in attr: do_backticks = True
- if "B" in attr: do_backticks = 2
- if "d" in attr: do_dashes = 1
- if "D" in attr: do_dashes = 2
- if "i" in attr: do_dashes = 3
- if "e" in attr: do_ellipses = True
- if "w" in attr: convert_quot = True
+ if 'q' in attr: do_quotes = True
+ if 'b' in attr: do_backticks = True
+ if 'B' in attr: do_backticks = 2
+ if 'd' in attr: do_dashes = 1
+ if 'D' in attr: do_dashes = 2
+ if 'i' in attr: do_dashes = 3
+ if 'e' in attr: do_ellipses = True
+ if 'w' in attr: convert_quot = True
- prev_token_last_char = " "
+ prev_token_last_char = ' '
# Last character of the previous text token. Used as
# context to curl leading quote characters correctly.
Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py 2022-03-04 15:57:13 UTC (rev 9026)
+++ trunk/docutils/docutils/writers/_html_base.py 2022-03-05 23:27:30 UTC (rev 9027)
@@ -18,7 +18,8 @@
import base64
import mimetypes
-import os, os.path
+import os
+import os.path
import re
from urllib.request import url2pathname
import warnings
Modified: trunk/docutils/test/alltests.py
===================================================================
--- trunk/docutils/test/alltests.py 2022-03-04 15:57:13 UTC (rev 9026)
+++ trunk/docutils/test/alltests.py 2022-03-05 23:27:30 UTC (rev 9027)
@@ -14,15 +14,15 @@
import time
# Start point for actual elapsed time, including imports
# and setup outside of unittest.
-start = time.time() # noqa
+start = time.time()
-import sys
-import atexit
-import os
-import platform
+import sys # noqa: E402
+import atexit # noqa: E402
+import os # noqa: E402
+import platform # noqa: E402
-import DocutilsTestSupport # must be imported before docutils
-import docutils
+import DocutilsTestSupport # noqa: E402 must be imported before docutils
+import docutils # noqa: E402
class Tee:
Modified: trunk/docutils/test/functional/tests/standalone_rst_s5_html_1.py
===================================================================
--- trunk/docutils/test/functional/tests/standalone_rst_s5_html_1.py 2022-03-04 15:57:13 UTC (rev 9026)
+++ trunk/docutils/test/functional/tests/standalone_rst_s5_html_1.py 2022-03-05 23:27:30 UTC (rev 9027)
@@ -1,3 +1,6 @@
+import filecmp as _filecmp
+
+
with open('functional/tests/_standalone_rst_defaults.py') as _f:
exec(_f.read())
@@ -17,9 +20,6 @@
# Extra functional tests.
# Prefix all names with '_' to avoid confusing `docutils.core.publish_file`.
-import filecmp as _filecmp
-
-
def _test_more(expected_dir, output_dir, test_case, parameters):
"""Compare ``ui/<theme>`` directories."""
theme = settings_overrides.get('theme', 'default')
Modified: trunk/docutils/test/test_error_reporting.py
===================================================================
--- trunk/docutils/test/test_error_reporting.py 2022-03-04 15:57:13 UTC (rev 9026)
+++ trunk/docutils/test/test_error_reporting.py 2022-03-05 23:27:30 UTC (rev 9027)
@@ -29,14 +29,15 @@
import sys
import unittest
import warnings
-warnings.filterwarnings('ignore', category=DeprecationWarning,
- message=r'.*utils\.error_reporting')
import DocutilsTestSupport # must be imported before docutils
from docutils import core, parsers, frontend, utils
from docutils.utils.error_reporting import SafeString, ErrorString, ErrorOutput
+warnings.filterwarnings('ignore', category=DeprecationWarning,
+ message=r'.*utils\.error_reporting')
+
class SafeStringTests(unittest.TestCase):
# test data:
Modified: trunk/docutils/test/test_language.py
===================================================================
--- trunk/docutils/test/test_language.py 2022-03-04 15:57:13 UTC (rev 9026)
+++ trunk/docutils/test/test_language.py 2022-03-05 23:27:30 UTC (rev 9027)
@@ -15,11 +15,13 @@
import sys
import os
import re
+
import DocutilsTestSupport # must be imported before docutils
import docutils.languages
import docutils.parsers.rst.languages
from docutils.parsers.rst import states, directives, roles
-import docutils.utils, docutils.frontend
+import docutils.utils
+import docutils.frontend
_settings = docutils.frontend.OptionParser().get_default_values()
_reporter = docutils.utils.new_reporter('', _settings)
Modified: trunk/docutils/tox.ini
===================================================================
--- trunk/docutils/tox.ini 2022-03-04 15:57:13 UTC (rev 9026)
+++ trunk/docutils/tox.ini 2022-03-05 23:27:30 UTC (rev 9027)
@@ -38,8 +38,6 @@
# whitespace around the operators with the lowest priority(ies).
# Use your own judgment; …"
- E401, # multiple imports on one line
- E402, # module level import not at top of file
E501, # line too long (N > 79 characters)
E502, # the backslash is redundant between brackets
E701, # multiple statements on one line (colon)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|