SF.net SVN: docutils:[9829 ] trunk/docutils

aa-turner--- via Docutils-checkins <[email protected]>
Newsgroups gmane.text.docutils.cvs
Message-ID <[email protected]>
Revision: 9829
          http://sourceforge.net/p/docutils/code/9829
Author:   aa-turner
Date:     2024-08-01 20:47:11 +0000 (Thu, 01 Aug 2024)
Log Message:
-----------
Enable the pygrep-hooks linter in Ruff

Modified Paths:
--------------
    trunk/docutils/.ruff.toml
    trunk/docutils/docutils/__init__.py
    trunk/docutils/docutils/frontend.py
    trunk/docutils/docutils/io.py
    trunk/docutils/docutils/nodes.py
    trunk/docutils/docutils/parsers/recommonmark_wrapper.py
    trunk/docutils/docutils/statemachine.py
    trunk/docutils/docutils/utils/smartquotes.py
    trunk/docutils/test/test_language.py
    trunk/docutils/test/test_parsers/test_rst/test_directives/test_date.py

Modified: trunk/docutils/.ruff.toml
===================================================================
--- trunk/docutils/.ruff.toml	2024-08-01 20:41:32 UTC (rev 9828)
+++ trunk/docutils/.ruff.toml	2024-08-01 20:47:11 UTC (rev 9829)
@@ -14,6 +14,7 @@
     "INP",  # flake8-no-pep420
     "INT",  # flake8-gettext
     "LOG",  # flake8-logging
+    "PGH",  # pygrep-hooks
     "W",    # pycodestyle
 ]
 ignore = [

Modified: trunk/docutils/docutils/__init__.py
===================================================================
--- trunk/docutils/docutils/__init__.py	2024-08-01 20:41:32 UTC (rev 9828)
+++ trunk/docutils/docutils/__init__.py	2024-08-01 20:47:11 UTC (rev 9829)
@@ -125,7 +125,7 @@
                 raise ValueError('releaselevel "final" must not be used '
                                  'with development versions (leads to wrong '
                                  'version ordering of the related __version__')
-                # cf. https://peps.python.org/pep-0440/#summary-of-permitted-suffixes-and-relative-ordering  # noqa
+                # cf. https://peps.python.org/pep-0440/#summary-of-permitted-suffixes-and-relative-ordering  # NoQA: E501
             if serial != 0:
                 raise ValueError('"serial" must be 0 for final releases')
 

Modified: trunk/docutils/docutils/frontend.py
===================================================================
--- trunk/docutils/docutils/frontend.py	2024-08-01 20:41:32 UTC (rev 9828)
+++ trunk/docutils/docutils/frontend.py	2024-08-01 20:47:11 UTC (rev 9829)
@@ -677,7 +677,7 @@
 
     default_error_encoding: ClassVar[str] = (
         getattr(sys.stderr, 'encoding', None)
-        or io._locale_encoding  # noqa
+        or io._locale_encoding
         or 'ascii'
     )
 

Modified: trunk/docutils/docutils/io.py
===================================================================
--- trunk/docutils/docutils/io.py	2024-08-01 20:41:32 UTC (rev 9828)
+++ trunk/docutils/docutils/io.py	2024-08-01 20:47:11 UTC (rev 9829)
@@ -39,7 +39,8 @@
         _locale_encoding: str | None = (
             locale.getlocale()[1] or locale.getdefaultlocale()[1]
         ).lower()
-except:  # noqa  any other problems determining the locale -> use None
+except:  # NoQA: E722
+    # any other problems determining the locale -> use None
     _locale_encoding = None
 try:
     codecs.lookup(_locale_encoding)

Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py	2024-08-01 20:41:32 UTC (rev 9828)
+++ trunk/docutils/docutils/nodes.py	2024-08-01 20:47:11 UTC (rev 9829)
@@ -2589,7 +2589,7 @@
             children = (p,) + children
         try:
             Element.__init__(self, rawsource, *children, **attributes)
-        except:  # noqa  catchall
+        except:  # NoQA: E722
             print('system_message: children=%r' % (children,))
             raise
 

Modified: trunk/docutils/docutils/parsers/recommonmark_wrapper.py
===================================================================
--- trunk/docutils/docutils/parsers/recommonmark_wrapper.py	2024-08-01 20:41:32 UTC (rev 9828)
+++ trunk/docutils/docutils/parsers/recommonmark_wrapper.py	2024-08-01 20:47:11 UTC (rev 9829)
@@ -35,7 +35,8 @@
     import sys
     import types
 
-    class pending_xref(nodes.Inline, nodes.Element): ... # NoQA
+    class pending_xref(nodes.Inline, nodes.Element):
+        ...
 
     sys.modules['sphinx'] = sphinx = types.ModuleType('sphinx')
     sphinx.addnodes = addnodes = types.SimpleNamespace()

Modified: trunk/docutils/docutils/statemachine.py
===================================================================
--- trunk/docutils/docutils/statemachine.py	2024-08-01 20:41:32 UTC (rev 9828)
+++ trunk/docutils/docutils/statemachine.py	2024-08-01 20:47:11 UTC (rev 9829)
@@ -264,7 +264,7 @@
                 else:
                     transitions = None
                 state = self.get_state(next_state)
-        except:  # noqa  catchall
+        except:  # NoQA: E722
             if self.debug:
                 self.error()
             raise
@@ -674,7 +674,7 @@
         try:
             del self.transitions[name]
             self.transition_order.remove(name)
-        except:  # noqa  catchall
+        except:  # NoQA: E722
             raise UnknownTransitionError(name)
 
     def make_transition(self, name, next_state=None):
@@ -1103,13 +1103,24 @@
     def __repr__(self) -> str:
         return f'{self.__class__.__name__}({self.data}, items={self.items})'
 
-    def __lt__(self, other): return self.data < self.__cast(other)   # noqa
-    def __le__(self, other): return self.data <= self.__cast(other)  # noqa
-    def __eq__(self, other): return self.data == self.__cast(other)  # noqa
-    def __ne__(self, other): return self.data != self.__cast(other)  # noqa
-    def __gt__(self, other): return self.data > self.__cast(other)   # noqa
-    def __ge__(self, other): return self.data >= self.__cast(other)  # noqa
+    def __lt__(self, other):
+        return self.data < self.__cast(other)
 
+    def __le__(self, other):
+        return self.data <= self.__cast(other)
+
+    def __eq__(self, other):
+        return self.data == self.__cast(other)
+
+    def __ne__(self, other):
+        return self.data != self.__cast(other)
+
+    def __gt__(self, other):
+        return self.data > self.__cast(other)
+
+    def __ge__(self, other):
+        return self.data >= self.__cast(other)
+
     def __cast(self, other):
         if isinstance(other, ViewList):
             return other.data

Modified: trunk/docutils/docutils/utils/smartquotes.py
===================================================================
--- trunk/docutils/docutils/utils/smartquotes.py	2024-08-01 20:41:32 UTC (rev 9828)
+++ trunk/docutils/docutils/utils/smartquotes.py	2024-08-01 20:47:11 UTC (rev 9829)
@@ -911,7 +911,7 @@
     try:
         locale.setlocale(locale.LC_ALL, '')  # set to user defaults
         defaultlanguage = locale.getlocale()[0]
-    except:  # noqa  catchall
+    except:  # NoQA: E722
         defaultlanguage = 'en'
 
     # Normalize and drop unsupported subtags:

Modified: trunk/docutils/test/test_language.py
===================================================================
--- trunk/docutils/test/test_language.py	2024-08-01 20:41:32 UTC (rev 9828)
+++ trunk/docutils/test/test_language.py	2024-08-01 20:47:11 UTC (rev 9829)
@@ -26,8 +26,8 @@
 
 from docutils import frontend, languages, utils
 from docutils.parsers.rst import languages as rst_languages
-from docutils.parsers.rst.directives import _directive_registry  # NoQA
-from docutils.parsers.rst.roles import _role_registry  # NoQA
+from docutils.parsers.rst.directives import _directive_registry
+from docutils.parsers.rst.roles import _role_registry
 
 LANGUAGE_MODULE_PATTERN = re.compile(r'^([a-z]{2,3}(_[a-z]{2,8})*)\.py$')
 REPORTER = utils.new_reporter('', frontend.get_default_settings())

Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_date.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_date.py	2024-08-01 20:41:32 UTC (rev 9828)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_date.py	2024-08-01 20:47:11 UTC (rev 9829)
@@ -18,7 +18,7 @@
     # so we import the local `docutils` package.
     sys.path.insert(0, str(Path(__file__).resolve().parents[4]))
 
-from docutils.io import _locale_encoding  # noqa
+from docutils.io import _locale_encoding
 from docutils.frontend import get_default_settings
 from docutils.parsers.rst import Parser
 from docutils.utils import new_document

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.