Corrected some more code style issues. eric7

Tue, 29 Aug 2023 17:48:25 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 29 Aug 2023 17:48:25 +0200
branch
eric7
changeset 10170
6cf1ee737d8f
parent 10169
0f70a4ef4592
child 10171
15070a32c15b

Corrected some more code style issues.

scripts/install-debugclients.py file | annotate | diff | comparison | revisions
src/eric7/CycloneDXInterface/CycloneDXUtilities.py file | annotate | diff | comparison | revisions
src/eric7/DebugClients/Python/DebugVariables.py file | annotate | diff | comparison | revisions
src/eric7/MicroPython/Devices/CircuitPythonDevices.py file | annotate | diff | comparison | revisions
src/eric7/MicroPython/Devices/CircuitPythonUpdater/CircuitPythonUpdaterInterface.py file | annotate | diff | comparison | revisions
src/eric7/MicroPython/Devices/EspDevices.py file | annotate | diff | comparison | revisions
src/eric7/MicroPython/Devices/RP2040Devices.py file | annotate | diff | comparison | revisions
src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Annotations/AnnotationsFunctionVisitor.py file | annotate | diff | comparison | revisions
src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Miscellaneous/MiscellaneousChecker.py file | annotate | diff | comparison | revisions
src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/generalHardcodedPassword.py file | annotate | diff | comparison | revisions
src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/translations.py file | annotate | diff | comparison | revisions
src/eric7/SystemUtilities/FileSystemUtilities.py file | annotate | diff | comparison | revisions
--- a/scripts/install-debugclients.py	Tue Aug 29 16:55:18 2023 +0200
+++ b/scripts/install-debugclients.py	Tue Aug 29 17:48:25 2023 +0200
@@ -21,7 +21,7 @@
 import os
 import re
 import shutil
-import subprocess
+import subprocess  # secok
 import sys
 import sysconfig
 
--- a/src/eric7/CycloneDXInterface/CycloneDXUtilities.py	Tue Aug 29 16:55:18 2023 +0200
+++ b/src/eric7/CycloneDXInterface/CycloneDXUtilities.py	Tue Aug 29 17:48:25 2023 +0200
@@ -11,7 +11,7 @@
 import json
 import os
 
-from xml.etree import ElementTree
+from xml.etree import ElementTree  # secok
 
 from cyclonedx.model import (
     ExternalReference,
@@ -207,7 +207,7 @@
     @return prettified SBOM string
     @rtype str
     """
-    tree = ElementTree.fromstring(inputStr)
+    tree = ElementTree.fromstring(inputStr)  # secok
     with contextlib.suppress(AttributeError):
         ElementTree.indent(tree)
         return '<?xml version="1.0" encoding="UTF-8"?>\n' + ElementTree.tostring(
--- a/src/eric7/DebugClients/Python/DebugVariables.py	Tue Aug 29 16:55:18 2023 +0200
+++ b/src/eric7/DebugClients/Python/DebugVariables.py	Tue Aug 29 17:48:25 2023 +0200
@@ -52,11 +52,9 @@
         """
         d = []
         for name in dir(var):
-            try:
+            with contextlib.suppress(AttributeError):
                 attribute = getattr(var, name)
-            except Exception:
-                continue
-            d.append((name, attribute))
+                d.append((name, attribute))
 
         return d
 
@@ -83,11 +81,9 @@
         """
         d = []
         for name in dir(var):
-            try:
+            with contextlib.suppress(AttributeError):
                 attribute = getattr(var, name)
-            except Exception:
-                continue
-            d.append((name, attribute))
+                d.append((name, attribute))
 
         yield -1, d
         while True:
--- a/src/eric7/MicroPython/Devices/CircuitPythonDevices.py	Tue Aug 29 16:55:18 2023 +0200
+++ b/src/eric7/MicroPython/Devices/CircuitPythonDevices.py	Tue Aug 29 17:48:25 2023 +0200
@@ -1244,7 +1244,7 @@
         """
         if security is None or password is None:
             security = 0
-            password = ""
+            password = ""  # secok
         authmode = self.__securityCode2AuthModeString[security]
 
         if ifconfig:
--- a/src/eric7/MicroPython/Devices/CircuitPythonUpdater/CircuitPythonUpdaterInterface.py	Tue Aug 29 16:55:18 2023 +0200
+++ b/src/eric7/MicroPython/Devices/CircuitPythonUpdater/CircuitPythonUpdaterInterface.py	Tue Aug 29 17:48:25 2023 +0200
@@ -218,7 +218,7 @@
                 )
                 return
 
-            result = requests.head("https://github.com/" + bundle)
+            result = requests.head("https://github.com/" + bundle, timeout=30)
             if result.status_code == requests.codes.NOT_FOUND:
                 EricMessageBox.critical(
                     None,
--- a/src/eric7/MicroPython/Devices/EspDevices.py	Tue Aug 29 16:55:18 2023 +0200
+++ b/src/eric7/MicroPython/Devices/EspDevices.py	Tue Aug 29 17:48:25 2023 +0200
@@ -1158,7 +1158,7 @@
 
         if security is None or password is None:
             security = 0
-            password = ""
+            password = ""  # secok
         if security > 4:
             security = 4  # security >4 cause an error thrown by the ESP32
 
--- a/src/eric7/MicroPython/Devices/RP2040Devices.py	Tue Aug 29 16:55:18 2023 +0200
+++ b/src/eric7/MicroPython/Devices/RP2040Devices.py	Tue Aug 29 17:48:25 2023 +0200
@@ -1170,7 +1170,7 @@
         """
         if security is None or password is None:
             security = 0
-            password = ""
+            password = ""  # secok
 
         if self._deviceData["wifi_type"] == "picow":
             country = Preferences.getMicroPython("WifiCountry").upper()
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Annotations/AnnotationsFunctionVisitor.py	Tue Aug 29 16:55:18 2023 +0200
+++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Annotations/AnnotationsFunctionVisitor.py	Tue Aug 29 17:48:25 2023 +0200
@@ -573,10 +573,7 @@
             # In the event of an explicit `None` return (`return None`), the
             # node body will be an instance `ast.Constant` (3.8+), which we
             # need to check to see if it's actually `None`
-            if (
-                isinstance(node.value, ast.Constant)
-                and node.value.value is None
-            ):
+            if isinstance(node.value, ast.Constant) and node.value.value is None:
                 return
 
             self.__nonNoneReturnNodes.add(self.__context[-1])
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Miscellaneous/MiscellaneousChecker.py	Tue Aug 29 16:55:18 2023 +0200
+++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Miscellaneous/MiscellaneousChecker.py	Tue Aug 29 17:48:25 2023 +0200
@@ -2620,9 +2620,8 @@
 
         def emptyBody(body):
             def isStrOrEllipsis(node):
-                return (
-                    isinstance(node, ast.Constant)
-                    and (node.value is Ellipsis or isinstance(node.value, str))
+                return isinstance(node, ast.Constant) and (
+                    node.value is Ellipsis or isinstance(node.value, str)
                 )
 
             # Function body consist solely of `pass`, `...`, and/or (doc)string literals
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/generalHardcodedPassword.py	Tue Aug 29 16:55:18 2023 +0200
+++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/generalHardcodedPassword.py	Tue Aug 29 17:48:25 2023 +0200
@@ -70,8 +70,8 @@
                     node.value,
                 )
 
-    elif (
-        isinstance(node._securityParent, ast.Index) and RE_CANDIDATES.search(node.value)
+    elif isinstance(node._securityParent, ast.Index) and RE_CANDIDATES.search(
+        node.value
     ):
         # looks for "dict[candidate]='some_string'"
         # assign -> subscript -> index -> string
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/translations.py	Tue Aug 29 16:55:18 2023 +0200
+++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/translations.py	Tue Aug 29 17:48:25 2023 +0200
@@ -199,7 +199,7 @@
     "E721": QCoreApplication.translate(
         "pycodestyle",
         "do not compare types, for exact checks use 'is' / 'is not', "
-        "for instance checks use 'isinstance()'"
+        "for instance checks use 'isinstance()'",
     ),
     "E722": QCoreApplication.translate("pycodestyle", "do not use bare except"),
     "E731": QCoreApplication.translate(
--- a/src/eric7/SystemUtilities/FileSystemUtilities.py	Tue Aug 29 16:55:18 2023 +0200
+++ b/src/eric7/SystemUtilities/FileSystemUtilities.py	Tue Aug 29 17:48:25 2023 +0200
@@ -12,7 +12,7 @@
 import fnmatch
 import os
 import pathlib
-import subprocess
+import subprocess  # secok
 
 from eric7.SystemUtilities import OSUtilities
 

eric ide

mercurial