Corrected some code style and formatting issues.

Fri, 28 Jun 2024 16:36:46 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 28 Jun 2024 16:36:46 +0200
changeset 15
2fb8d19c38ae
parent 14
12413552ae0d
child 16
c06fb4cb120e

Corrected some code style and formatting issues.

PipxInterface/Pipx.py file | annotate | diff | comparison | revisions
PipxInterface/PipxInterpretersDialog.py file | annotate | diff | comparison | revisions
PipxInterface/PipxWidget.py file | annotate | diff | comparison | revisions
PluginPipxInterface.epj file | annotate | diff | comparison | revisions
PluginPipxInterface.py file | annotate | diff | comparison | revisions
--- a/PipxInterface/Pipx.py	Fri Jun 28 16:25:21 2024 +0200
+++ b/PipxInterface/Pipx.py	Fri Jun 28 16:36:46 2024 +0200
@@ -49,7 +49,7 @@
         @return string containing the pipx version number
         @rtype str
         """
-        from pipx.version import version
+        from pipx.version import version  # noqa: I102
 
         return version
 
@@ -60,7 +60,7 @@
         @return tuple containing the elements of the pipx version number
         @rtype tuple of (int, int, int)
         """
-        from pipx.version import version_tuple
+        from pipx.version import version_tuple  # noqa: I102
 
         return version_tuple
 
@@ -72,7 +72,7 @@
             'venvsPath', 'appsPath' and 'manPath'.
         @rtype dict[str, Path]
         """
-        from pipx.paths import ctx
+        from pipx.paths import ctx  # noqa: I102
 
         return {
             "venvsPath": ctx.venvs,
@@ -89,7 +89,7 @@
             'venvsPath', 'appsPath' and 'manPath'.
         @rtype dict[str, str]
         """
-        from pipx.paths import ctx
+        from pipx.paths import ctx  # noqa: I102
 
         return {
             "venvsPath": str(ctx.venvs),
@@ -176,13 +176,13 @@
         @return dictionary containing data of standalone interpreters
         @rtype dict
         """
-        from pipx.commands.interpreter import (
+        from pipx.commands.interpreter import (  # noqa: I102
             get_installed_standalone_interpreters,
-            get_venvs_using_standalone_interpreter,
             get_interpreter_users,
+            get_venvs_using_standalone_interpreter,
         )
-        from pipx.paths import ctx
-        from pipx.venv import VenvContainer
+        from pipx.paths import ctx  # noqa: I102
+        from pipx.venv import VenvContainer  # noqa: I102
 
         interpreters = get_installed_standalone_interpreters()
         venvs = get_venvs_using_standalone_interpreter(VenvContainer(ctx.venvs))
@@ -213,33 +213,32 @@
         @return list of dictionaries containing the installed packages and apps
         @rtype list of dict[str, str | list]
         """
-        from pipx.paths import ctx
+        from pipx.paths import ctx  # noqa: I102
 
         packages = []
 
         ok, output = self.runPipxProcess(["list", "--json"])
-        if ok:
-            if output:
-                with contextlib.suppress(json.JSONDecodeError):
-                    data = json.loads(output, object_hook=self.__metadataDecoderHook)
-                    for venvName in data["venvs"]:
-                        metadata = data["venvs"][venvName]["metadata"]
-                        package = {
-                            "name": venvName,
-                            "version": metadata["main_package"]["package_version"],
-                            "apps": [],
-                            "python": metadata["python_version"],
-                            "is_standalone": (
-                                str(metadata["source_interpreter"]).startswith(
-                                    str(ctx.standalone_python_cachedir.resolve())
-                                )
-                                if metadata["source_interpreter"]
-                                else False
-                            ),
-                        }
-                        for appPath in metadata["main_package"]["app_paths"]:
-                            package["apps"].append((appPath.name, str(appPath)))
-                        packages.append(package)
+        if ok and output:
+            with contextlib.suppress(json.JSONDecodeError):
+                data = json.loads(output, object_hook=self.__metadataDecoderHook)
+                for venvName in data["venvs"]:
+                    metadata = data["venvs"][venvName]["metadata"]
+                    package = {
+                        "name": venvName,
+                        "version": metadata["main_package"]["package_version"],
+                        "apps": [],
+                        "python": metadata["python_version"],
+                        "is_standalone": (
+                            str(metadata["source_interpreter"]).startswith(
+                                str(ctx.standalone_python_cachedir.resolve())
+                            )
+                            if metadata["source_interpreter"]
+                            else False
+                        ),
+                    }
+                    for appPath in metadata["main_package"]["app_paths"]:
+                        package["apps"].append((appPath.name, str(appPath)))
+                    packages.append(package)
 
         return packages
 
@@ -360,7 +359,7 @@
         fetchMissingInterpreter=False,
     ):
         """
-        Public method to reinstall the given package with given options
+        Public method to reinstall the given package with given options.
 
         @param package name of the package to reinstall
         @type str
@@ -389,10 +388,8 @@
         skipPackages=None,
     ):
         """
-        Public method to reinstall all packages with given options
+        Public method to reinstall all packages with given options.
 
-        @param package name of the package to reinstall
-        @type str
         @param interpreterVersion version of the Python interpreter (defaults to "")
         @type str (optional)
         @param fetchMissingInterpreter flag indicating to fetch a standalone Python
@@ -511,8 +508,8 @@
     def upgradeInterpreters(self, dialogParent=None):
         """
         Public method to upgrade the installed interpreters to the latest available
-        micro/patch version
-        
+        micro/patch version.
+
         @param dialogParent parent widget of the execution dialog
         @type QWidget
         """
@@ -525,7 +522,7 @@
     def pruneInterpreters(self, dialogParent=None):
         """
         Public method to prune unused interpreters.
-        
+
         @param dialogParent parent widget of the execution dialog
         @type QWidget
         """
--- a/PipxInterface/PipxInterpretersDialog.py	Fri Jun 28 16:25:21 2024 +0200
+++ b/PipxInterface/PipxInterpretersDialog.py	Fri Jun 28 16:36:46 2024 +0200
@@ -56,19 +56,22 @@
                 [
                     self.tr("Python {0}{1}").format(
                         interpreter,
-                        ""
-                        if interpreters[interpreter]["used"]
-                        else self.tr(" (unused)"),
+                        (
+                            ""
+                            if interpreters[interpreter]["used"]
+                            else self.tr(" (unused)")
+                        ),
                     )
-                ]
+                ],
             )
             for package, packageVersion in interpreters[interpreter]["used_by"]:
                 QTreeWidgetItem(
                     pyItem,
                     [
-                        self.tr("{0} {1}", "package, version")
-                        .format(package, packageVersion)
-                    ]
+                        self.tr("{0} {1}", "package, version").format(
+                            package, packageVersion
+                        )
+                    ],
                 )
                 pyItem.setExpanded(True)
 
--- a/PipxInterface/PipxWidget.py	Fri Jun 28 16:25:21 2024 +0200
+++ b/PipxInterface/PipxWidget.py	Fri Jun 28 16:36:46 2024 +0200
@@ -18,7 +18,6 @@
 
 from .Pipx import Pipx
 from .PipxAppStartDialog import PipxAppStartDialog
-
 from .Ui_PipxWidget import Ui_PipxWidget
 
 
@@ -385,9 +384,7 @@
         yes = EricMessageBox.yesNo(
             self,
             self.tr("Uninstall All Packages"),
-            self.tr(
-                "<p>Do you really want to uninstall <b>ALL</b> packages?</p>"
-            ),
+            self.tr("<p>Do you really want to uninstall <b>ALL</b> packages?</p>"),
         )
         if yes:
             self.__pipx.uninstallAllPackages()
@@ -437,8 +434,9 @@
         item.setData(0, PipxWidget.LatestVersionRole, latestVersion)
         item.setText(
             PipxWidget.VersionColumn,
-            self.tr("{0} ({1})", "current version, latest version")
-            .format(version, latestVersion),
+            self.tr("{0} ({1})", "current version, latest version").format(
+                version, latestVersion
+            ),
         )
 
     def __populatePackages(self):
@@ -454,8 +452,7 @@
                 [
                     package["name"],
                     package["version"],
-                    self.tr("{0}{1}", "Python version, standalone indicator")
-                    .format(
+                    self.tr("{0}{1}", "Python version, standalone indicator").format(
                         package["python"],
                         self.tr(" (standalone)") if package["is_standalone"] else "",
                     ),
@@ -503,7 +500,7 @@
     @pyqtSlot(QTreeWidgetItem, int)
     def on_packagesList_itemActivated(self, item, column):
         """
-        Private slot to start the activated item, if it is not a top level one
+        Private slot to start the activated item, if it is not a top level one.
 
         @param item reference to the activated item
         @type QTreeWidgetItem
--- a/PluginPipxInterface.epj	Fri Jun 28 16:25:21 2024 +0200
+++ b/PluginPipxInterface.epj	Fri Jun 28 16:36:46 2024 +0200
@@ -5,7 +5,151 @@
   },
   "project": {
     "AUTHOR": "Detlev Offenbach",
-    "CHECKERSPARMS": {},
+    "CHECKERSPARMS": {
+      "Pep8Checker": {
+        "AnnotationsChecker": {
+          "AllowStarArgAny": false,
+          "AllowUntypedDefs": false,
+          "AllowUntypedNested": false,
+          "CheckFutureAnnotations": false,
+          "DispatchDecorators": [
+            "singledispatch",
+            "singledispatchmethod"
+          ],
+          "ExemptedTypingSymbols": [
+            ""
+          ],
+          "ForceFutureAnnotations": false,
+          "MaximumComplexity": 3,
+          "MaximumLength": 7,
+          "MinimumCoverage": 75,
+          "MypyInitReturn": false,
+          "OverloadDecorators": [
+            "overload"
+          ],
+          "RespectTypeIgnore": false,
+          "SuppressDummyArgs": false,
+          "SuppressNoneReturning": true
+        },
+        "BlankLines": [
+          2,
+          1
+        ],
+        "BuiltinsChecker": {
+          "bytes": [
+            "unicode"
+          ],
+          "chr": [
+            "unichr"
+          ],
+          "str": [
+            "unicode"
+          ]
+        },
+        "CommentedCodeChecker": {
+          "Aggressive": false,
+          "WhiteList": [
+            "pylint",
+            "pyright",
+            "noqa",
+            "type:\\s*ignore",
+            "fmt:\\s*(on|off)",
+            "TODO",
+            "FIXME",
+            "WARNING",
+            "NOTE",
+            "TEST",
+            "DOCU",
+            "XXX",
+            "- "
+          ]
+        },
+        "CopyrightAuthor": "",
+        "CopyrightMinFileSize": 0,
+        "DocstringType": "eric_black",
+        "EnabledCheckerCategories": "ASY, C, D, E, I, L, M, NO, N, Y, U, W",
+        "ExcludeFiles": "*/Ui_*.py",
+        "ExcludeMessages": "C101,E203,E265,E266,E305,E402,M201,M701,M702,M811,M834,M852,N802,N803,N807,N808,N821,U101,W293,W503,Y119,Y401,Y402",
+        "FixCodes": "",
+        "FixIssues": false,
+        "FutureChecker": "",
+        "HangClosing": false,
+        "ImportsChecker": {
+          "ApplicationPackageNames": [
+            "eric7"
+          ],
+          "BanRelativeImports": "",
+          "BannedModules": []
+        },
+        "IncludeMessages": "",
+        "LineComplexity": 25,
+        "LineComplexityScore": 10,
+        "MaxCodeComplexity": 10,
+        "MaxDocLineLength": 88,
+        "MaxLineLength": 88,
+        "NameOrderChecker": {
+          "ApplicationPackageNames": [
+            "eric7"
+          ],
+          "CombinedAsImports": true,
+          "SortCaseSensitive": false,
+          "SortFromFirst": false,
+          "SortIgnoringStyle": false,
+          "SortOrder": "natural"
+        },
+        "NoFixCodes": "E501",
+        "RepeatMessages": true,
+        "SecurityChecker": {
+          "CheckTypedException": false,
+          "HardcodedTmpDirectories": [
+            "/tmp",
+            "/var/tmp",
+            "/dev/shm",
+            "~/tmp"
+          ],
+          "InsecureHashes": [
+            "md4",
+            "md5",
+            "sha",
+            "sha1"
+          ],
+          "InsecureSslProtocolVersions": [
+            "PROTOCOL_SSLv2",
+            "SSLv2_METHOD",
+            "SSLv23_METHOD",
+            "PROTOCOL_SSLv3",
+            "PROTOCOL_TLSv1",
+            "SSLv3_METHOD",
+            "TLSv1_METHOD"
+          ],
+          "WeakKeySizeDsaHigh": "1024",
+          "WeakKeySizeDsaMedium": "2048",
+          "WeakKeySizeEcHigh": "160",
+          "WeakKeySizeEcMedium": "224",
+          "WeakKeySizeRsaHigh": "1024",
+          "WeakKeySizeRsaMedium": "2048"
+        },
+        "ShowIgnored": false,
+        "UnusedChecker": {
+          "IgnoreAbstract": true,
+          "IgnoreDunderGlobals": true,
+          "IgnoreDunderMethods": true,
+          "IgnoreEventHandlerMethods": true,
+          "IgnoreLambdas": false,
+          "IgnoreNestedFunctions": false,
+          "IgnoreOverload": true,
+          "IgnoreOverride": true,
+          "IgnoreSlotMethods": true,
+          "IgnoreStubs": true,
+          "IgnoreVariadicNames": false
+        },
+        "ValidEncodings": "latin-1, utf-8"
+      },
+      "SyntaxChecker": {
+        "AdditionalBuiltins": "",
+        "ExcludeFiles": "*/Ui_*.py"
+      }
+    },
     "DESCRIPTION": "This plugin implements widgets and dialogs to interact with the 'pipx' application management command.",
     "DOCSTRING": "ericdoc",
     "DOCUMENTATIONPARMS": {},
--- a/PluginPipxInterface.py	Fri Jun 28 16:25:21 2024 +0200
+++ b/PluginPipxInterface.py	Fri Jun 28 16:36:46 2024 +0200
@@ -94,8 +94,9 @@
     @return reference to the configuration page
     @rtype AutoCompletionRopePage
     """
+    from PipxInterface.ConfigurationPage.PipxPage import PipxPage  # noqa: I102
+
     global pipxInterfacePluginObject
-    from PipxInterface.ConfigurationPage.PipxPage import PipxPage  # noqa: I101
 
     page = PipxPage(pipxInterfacePluginObject)
     return page
@@ -168,12 +169,12 @@
         @return tuple of None and activation status
         @rtype bool
         """
+        from PipxInterface.PipxWidget import PipxWidget  # noqa: I102
+
         global error, pipxInterfacePluginObject
         error = ""  # clear previous error
         pipxInterfacePluginObject = self
 
-        from PipxInterface.PipxWidget import PipxWidget
-
         self.__widget = PipxWidget(self, fromEric=True)
         iconName = "pipx96" if self.__ui.getLayoutType() == "Sidebars" else "pipx22"
         self.__ui.addSideWidget(

eric ide

mercurial