aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDmitrii Agibov <dmitrii.agibov@arm.com>2022-09-16 13:34:35 +0100
committerDmitrii Agibov <dmitrii.agibov@arm.com>2022-09-20 16:51:58 +0100
commitc4ad3da5c63abb506833303564bd53e200ee8d97 (patch)
tree99d3d8f8cbe6068241dd49e3da80594b85793f26 /src
parent61684f9a4691449dc8aa129976789e3feab2b713 (diff)
downloadmlia-c4ad3da5c63abb506833303564bd53e200ee8d97.tar.gz
Make python syntax consistent across codebase
- Use pyupgrade tool for the syntax upgrade Change-Id: I3b9ae6cc5da193329e37028cde967ae049388361
Diffstat (limited to 'src')
-rw-r--r--src/mlia/backend/application.py4
-rw-r--r--src/mlia/backend/execution.py6
-rw-r--r--src/mlia/backend/proc.py2
-rw-r--r--src/mlia/cli/config.py8
-rw-r--r--src/mlia/cli/logging.py4
-rw-r--r--src/mlia/core/events.py2
-rw-r--r--src/mlia/devices/ethosu/reporters.py2
-rw-r--r--src/mlia/tools/metadata/common.py4
-rw-r--r--src/mlia/utils/filesystem.py4
9 files changed, 17 insertions, 19 deletions
diff --git a/src/mlia/backend/application.py b/src/mlia/backend/application.py
index a093afe..a5d99f7 100644
--- a/src/mlia/backend/application.py
+++ b/src/mlia/backend/application.py
@@ -88,11 +88,11 @@ def remove_application(directory_name: str) -> None:
def get_unique_application_names(system_name: str | None = None) -> list[str]:
"""Extract a list of unique application names of all application available."""
return list(
- set(
+ {
application.name
for application in get_available_applications()
if not system_name or application.can_run_on(system_name)
- )
+ }
)
diff --git a/src/mlia/backend/execution.py b/src/mlia/backend/execution.py
index f3fe401..5c8e53f 100644
--- a/src/mlia/backend/execution.py
+++ b/src/mlia/backend/execution.py
@@ -143,10 +143,8 @@ class ParamResolver:
if not param_value:
raise ConfigurationException(
- (
- "No value for parameter with index or "
- f"alias {index_or_alias} of command {cmd_name}."
- )
+ "No value for parameter with index or "
+ f"alias {index_or_alias} of command {cmd_name}."
)
return param_value
diff --git a/src/mlia/backend/proc.py b/src/mlia/backend/proc.py
index 7b3e92a..4838e47 100644
--- a/src/mlia/backend/proc.py
+++ b/src/mlia/backend/proc.py
@@ -66,7 +66,7 @@ class ShellCommand:
out, err = _out, _err
if not _out and not _err:
- out, err = [str(item) for item in self.get_stdout_stderr_paths(cmd)]
+ out, err = (str(item) for item in self.get_stdout_stderr_paths(cmd))
return command(_out=out, _err=err, _tee=_tee, _bg=_bg, _bg_exc=False)
diff --git a/src/mlia/cli/config.py b/src/mlia/cli/config.py
index dc28fa2..30373e4 100644
--- a/src/mlia/cli/config.py
+++ b/src/mlia/cli/config.py
@@ -29,11 +29,9 @@ def get_available_backends() -> list[str]:
# Add backends using backend manager
manager = get_installation_manager()
available_backends.extend(
- (
- backend
- for backend in backend_manager.supported_backends()
- if manager.backend_installed(backend)
- )
+ backend
+ for backend in backend_manager.supported_backends()
+ if manager.backend_installed(backend)
)
return available_backends
diff --git a/src/mlia/cli/logging.py b/src/mlia/cli/logging.py
index 40f47d3..e786394 100644
--- a/src/mlia/cli/logging.py
+++ b/src/mlia/cli/logging.py
@@ -31,10 +31,10 @@ def setup_logging(
:param verbose: enable extended logging for the tools loggers
:param log_filename: name of the log file in the logs directory
"""
- mlia_logger, *tools_loggers = [
+ mlia_logger, *tools_loggers = (
logging.getLogger(logger_name)
for logger_name in ["mlia", "tensorflow", "py.warnings"]
- ]
+ )
# enable debug output, actual message filtering depends on
# the provided parameters and being done on the handlers level
diff --git a/src/mlia/core/events.py b/src/mlia/core/events.py
index 71c86e2..e328cc1 100644
--- a/src/mlia/core/events.py
+++ b/src/mlia/core/events.py
@@ -284,7 +284,7 @@ class EventDispatcherMetaclass(type):
event_handler_methods = (
(item_name, item)
for item_name in dir(new_class)
- if callable((item := getattr(new_class, item_name)))
+ if callable(item := getattr(new_class, item_name))
and item_name.startswith(event_handler_method_prefix)
)
diff --git a/src/mlia/devices/ethosu/reporters.py b/src/mlia/devices/ethosu/reporters.py
index f11430c..9181043 100644
--- a/src/mlia/devices/ethosu/reporters.py
+++ b/src/mlia/devices/ethosu/reporters.py
@@ -41,7 +41,7 @@ def report_operators_stat(operators: Operators) -> Report:
operators.npu_supported_number,
Cell(
operators.npu_unsupported_ratio * 100,
- fmt=Format(str_fmt="{0:.0f}%".format),
+ fmt=Format(str_fmt="{:.0f}%".format),
),
)
]
diff --git a/src/mlia/tools/metadata/common.py b/src/mlia/tools/metadata/common.py
index 32da4a4..dd4571a 100644
--- a/src/mlia/tools/metadata/common.py
+++ b/src/mlia/tools/metadata/common.py
@@ -199,7 +199,7 @@ class DefaultInstallationManager(InstallationManager, InstallationFiltersMixin):
return None
if len(installs) != 1:
- names = ",".join((install.name for install in installs))
+ names = ",".join(install.name for install in installs)
logger.info(
"Unable to correctly detect type of the installed FVP."
"The following FVPs are detected %s. Installation skipped.",
@@ -241,7 +241,7 @@ class DefaultInstallationManager(InstallationManager, InstallationFiltersMixin):
logger.info("No backends available for the installation.")
return
- names = ",".join((installation.name for installation in installations))
+ names = ",".join(installation.name for installation in installations)
logger.info("Following backends are available for downloading: %s", names)
for installation in installations:
diff --git a/src/mlia/utils/filesystem.py b/src/mlia/utils/filesystem.py
index 25619c5..fcd09b5 100644
--- a/src/mlia/utils/filesystem.py
+++ b/src/mlia/utils/filesystem.py
@@ -97,7 +97,9 @@ def file_chunks(
yield data
-def hexdigest(filepath: str | Path, hash_obj: "hashlib._Hash") -> str:
+def hexdigest(
+ filepath: str | Path, hash_obj: hashlib._Hash # pylint: disable=no-member
+) -> str:
"""Return hex digest of the file."""
for chunk in file_chunks(filepath):
hash_obj.update(chunk)