PipxInterface/Pipx.py

changeset 15
2fb8d19c38ae
parent 14
12413552ae0d
child 19
70b187d5a9df
--- 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
         """

eric ide

mercurial