diff --git a/platformio/account/team/commands/list.py b/platformio/account/team/commands/list.py index d0395d7c..5bdc8c14 100644 --- a/platformio/account/team/commands/list.py +++ b/platformio/account/team/commands/list.py @@ -48,11 +48,13 @@ def team_list_cmd(orgname, json_output): table_data.append( ( "Members:", - ", ".join( - (member.get("username") for member in team.get("members")) - ) - if team.get("members") - else "-", + ( + ", ".join( + (member.get("username") for member in team.get("members")) + ) + if team.get("members") + else "-" + ), ) ) click.echo(tabulate(table_data, tablefmt="plain")) diff --git a/platformio/builder/tools/pioplatform.py b/platformio/builder/tools/pioplatform.py index 4ce4b91d..f99a6ec5 100644 --- a/platformio/builder/tools/pioplatform.py +++ b/platformio/builder/tools/pioplatform.py @@ -75,9 +75,11 @@ def LoadPioPlatform(env): continue env.PrependENVPath( "PATH", - os.path.join(pkg.path, "bin") - if os.path.isdir(os.path.join(pkg.path, "bin")) - else pkg.path, + ( + os.path.join(pkg.path, "bin") + if os.path.isdir(os.path.join(pkg.path, "bin")) + else pkg.path + ), ) if ( not IS_WINDOWS diff --git a/platformio/check/cli.py b/platformio/check/cli.py index 1deced87..3e0c1759 100644 --- a/platformio/check/cli.py +++ b/platformio/check/cli.py @@ -122,9 +122,11 @@ def cli( silent=silent, src_filters=env_src_filters, flags=flags or env_options.get("check_flags"), - severity=[DefectItem.SEVERITY_LABELS[DefectItem.SEVERITY_HIGH]] - if silent - else severity or config.get("env:" + envname, "check_severity"), + severity=( + [DefectItem.SEVERITY_LABELS[DefectItem.SEVERITY_HIGH]] + if silent + else severity or config.get("env:" + envname, "check_severity") + ), skip_packages=skip_packages or env_options.get("check_skip_packages"), platform_packages=env_options.get("platform_packages"), ) @@ -142,9 +144,11 @@ def cli( result = {"env": envname, "tool": tool, "duration": time()} rc = ct.check( - on_defect_callback=None - if (json_output or verbose) - else lambda defect: click.echo(repr(defect)) + on_defect_callback=( + None + if (json_output or verbose) + else lambda defect: click.echo(repr(defect)) + ) ) result["defects"] = ct.get_defects() diff --git a/platformio/debug/config/base.py b/platformio/debug/config/base.py index 212d00fa..2a9f2235 100644 --- a/platformio/debug/config/base.py +++ b/platformio/debug/config/base.py @@ -194,9 +194,11 @@ class DebugConfigBase: # pylint: disable=too-many-instance-attributes cwd=server_package_dir if server_package else None, executable=result.get("executable"), arguments=[ - a.replace("$PACKAGE_DIR", server_package_dir) - if server_package_dir - else a + ( + a.replace("$PACKAGE_DIR", server_package_dir) + if server_package_dir + else a + ) for a in result.get("arguments", []) ], ) diff --git a/platformio/device/list/util.py b/platformio/device/list/util.py index 3589ee26..3847969c 100644 --- a/platformio/device/list/util.py +++ b/platformio/device/list/util.py @@ -144,9 +144,9 @@ def list_mdns_services(): if service.properties: try: properties = { - k.decode("utf8"): v.decode("utf8") - if isinstance(v, bytes) - else v + k.decode("utf8"): ( + v.decode("utf8") if isinstance(v, bytes) else v + ) for k, v in service.properties.items() } json.dumps(properties) diff --git a/platformio/device/monitor/command.py b/platformio/device/monitor/command.py index 3d3190fe..87f64449 100644 --- a/platformio/device/monitor/command.py +++ b/platformio/device/monitor/command.py @@ -125,9 +125,11 @@ def device_monitor_cmd(**options): options = apply_project_monitor_options(options, project_options) register_filters(platform=platform, options=options) options["port"] = SerialPortFinder( - board_config=platform.board_config(project_options.get("board")) - if platform and project_options.get("board") - else None, + board_config=( + platform.board_config(project_options.get("board")) + if platform and project_options.get("board") + else None + ), upload_protocol=project_options.get("upload_protocol"), ensure_ready=True, ).find(initial_port=options["port"]) diff --git a/platformio/home/rpc/handlers/project.py b/platformio/home/rpc/handlers/project.py index 2c03a7c9..817bb210 100644 --- a/platformio/home/rpc/handlers/project.py +++ b/platformio/home/rpc/handlers/project.py @@ -372,15 +372,19 @@ class ProjectRPC(BaseRPCHandler): return dict( platform=dict( - ownername=platform_pkg.metadata.spec.owner - if platform_pkg.metadata.spec - else None, + ownername=( + platform_pkg.metadata.spec.owner + if platform_pkg.metadata.spec + else None + ), name=platform.name, title=platform.title, version=str(platform_pkg.metadata.version), ), - board=platform.board_config(board_id).get_brief_data() - if board_id - else None, + board=( + platform.board_config(board_id).get_brief_data() + if board_id + else None + ), frameworks=frameworks or None, ) diff --git a/platformio/http.py b/platformio/http.py index 563f982f..18bb50c6 100644 --- a/platformio/http.py +++ b/platformio/http.py @@ -63,9 +63,11 @@ class HTTPSession(requests.Session): kwargs["timeout"] = __default_requests_timeout__ return super().request( method, - url - if url.startswith("http") or not self._x_base_url - else urljoin(self._x_base_url, url), + ( + url + if url.startswith("http") or not self._x_base_url + else urljoin(self._x_base_url, url) + ), *args, **kwargs ) diff --git a/platformio/package/commands/install.py b/platformio/package/commands/install.py index d2976644..8c987c17 100644 --- a/platformio/package/commands/install.py +++ b/platformio/package/commands/install.py @@ -222,9 +222,11 @@ def _install_project_env_libraries(project_env, options): env_lm = LibraryPackageManager( os.path.join(config.get("platformio", "libdeps_dir"), project_env), - compatibility=PackageCompatibility(**compatibility_qualifiers) - if compatibility_qualifiers - else None, + compatibility=( + PackageCompatibility(**compatibility_qualifiers) + if compatibility_qualifiers + else None + ), ) private_lm = LibraryPackageManager( os.path.join(config.get("platformio", "lib_dir")) diff --git a/platformio/package/commands/search.py b/platformio/package/commands/search.py index ac71ef4c..c3f7d5cd 100644 --- a/platformio/package/commands/search.py +++ b/platformio/package/commands/search.py @@ -65,10 +65,12 @@ def print_search_item(item): click.echo( "%s • %s • Published on %s" % ( - item["type"].capitalize() - if item["tier"] == "community" - else click.style( - ("%s %s" % (item["tier"], item["type"])).title(), bold=True + ( + item["type"].capitalize() + if item["tier"] == "community" + else click.style( + ("%s %s" % (item["tier"], item["type"])).title(), bold=True + ) ), item["version"]["name"], util.parse_datetime(item["version"]["released_at"]).strftime("%c"), diff --git a/platformio/package/manager/_install.py b/platformio/package/manager/_install.py index fc4d5ddb..125766d3 100644 --- a/platformio/package/manager/_install.py +++ b/platformio/package/manager/_install.py @@ -98,9 +98,9 @@ class PackageManagerInstallMixin: else: pkg = self.install_from_registry( spec, - search_qualifiers=compatibility.to_search_qualifiers() - if compatibility - else None, + search_qualifiers=( + compatibility.to_search_qualifiers() if compatibility else None + ), ) if not pkg or not pkg.metadata: diff --git a/platformio/package/manifest/parser.py b/platformio/package/manifest/parser.py index d3fe6bfa..7694c8a8 100644 --- a/platformio/package/manifest/parser.py +++ b/platformio/package/manifest/parser.py @@ -294,9 +294,11 @@ class BaseManifestParser: if not matched_files: continue result[root] = dict( - name="Examples" - if root == examples_dir - else os.path.relpath(root, examples_dir), + name=( + "Examples" + if root == examples_dir + else os.path.relpath(root, examples_dir) + ), base=os.path.relpath(root, package_dir), files=matched_files, ) diff --git a/platformio/package/meta.py b/platformio/package/meta.py index b1c491d7..b9e3750d 100644 --- a/platformio/package/meta.py +++ b/platformio/package/meta.py @@ -485,9 +485,11 @@ class PackageItem: def __eq__(self, other): conds = [ - os.path.realpath(self.path) == os.path.realpath(other.path) - if self.path and other.path - else self.path == other.path, + ( + os.path.realpath(self.path) == os.path.realpath(other.path) + if self.path and other.path + else self.path == other.path + ), self.metadata == other.metadata, ] return all(conds) diff --git a/platformio/platform/_run.py b/platformio/platform/_run.py index 949a452d..2912371d 100644 --- a/platformio/platform/_run.py +++ b/platformio/platform/_run.py @@ -116,9 +116,9 @@ class PlatformRunMixin: args, stdout=proc.BuildAsyncPipe( line_callback=self._on_stdout_line, - data_callback=lambda data: None - if self.silent - else _write_and_flush(sys.stdout, data), + data_callback=lambda data: ( + None if self.silent else _write_and_flush(sys.stdout, data) + ), ), stderr=proc.BuildAsyncPipe( line_callback=self._on_stderr_line, diff --git a/platformio/project/commands/config.py b/platformio/project/commands/config.py index 5e4ed21f..214b0db1 100644 --- a/platformio/project/commands/config.py +++ b/platformio/project/commands/config.py @@ -82,9 +82,11 @@ def lint_configuration(json_output=False): ( click.style(error["type"], fg="red"), error["message"], - error.get("source", "") + (f":{error.get('lineno')}") - if "lineno" in error - else "", + ( + error.get("source", "") + (f":{error.get('lineno')}") + if "lineno" in error + else "" + ), ) for error in errors ], diff --git a/platformio/project/integration/generator.py b/platformio/project/integration/generator.py index d55f9aa7..3cb677f1 100644 --- a/platformio/project/integration/generator.py +++ b/platformio/project/integration/generator.py @@ -91,9 +91,11 @@ class ProjectGenerator: "default_debug_env_name": get_default_debug_env(self.config), "env_name": self.env_name, "user_home_dir": os.path.abspath(fs.expanduser("~")), - "platformio_path": sys.argv[0] - if os.path.isfile(sys.argv[0]) - else where_is_program("platformio"), + "platformio_path": ( + sys.argv[0] + if os.path.isfile(sys.argv[0]) + else where_is_program("platformio") + ), "env_path": os.getenv("PATH"), "env_pathsep": os.pathsep, } diff --git a/platformio/registry/access/commands/list.py b/platformio/registry/access/commands/list.py index ce9d8a6a..50073031 100644 --- a/platformio/registry/access/commands/list.py +++ b/platformio/registry/access/commands/list.py @@ -41,9 +41,11 @@ def access_list_cmd(owner, urn_type, json_output): # pylint: disable=unused-arg table_data.append( ( "Access:", - click.style("Private", fg="red") - if resource.get("private", False) - else "Public", + ( + click.style("Private", fg="red") + if resource.get("private", False) + else "Public" + ), ) ) table_data.append( diff --git a/platformio/registry/mirror.py b/platformio/registry/mirror.py index 4b4508f6..8805ffe5 100644 --- a/platformio/registry/mirror.py +++ b/platformio/registry/mirror.py @@ -54,9 +54,11 @@ class RegistryFileMirrorIterator: "head", self._url_parts.path, allow_redirects=False, - params=dict(bypass=",".join(self._visited_mirrors)) - if self._visited_mirrors - else None, + params=( + dict(bypass=",".join(self._visited_mirrors)) + if self._visited_mirrors + else None + ), x_with_authorization=RegistryClient.allowed_private_packages(), ) stop_conditions = [ diff --git a/platformio/remote/client/device_monitor.py b/platformio/remote/client/device_monitor.py index 1499dd58..4e1ccb2f 100644 --- a/platformio/remote/client/device_monitor.py +++ b/platformio/remote/client/device_monitor.py @@ -123,9 +123,11 @@ class DeviceMonitorClient( # pylint: disable=too-many-instance-attributes index=i + 1, host=device[0] + ":" if len(result) > 1 else "", port=device[1]["port"], - description=device[1]["description"] - if device[1]["description"] != "n/a" - else "", + description=( + device[1]["description"] + if device[1]["description"] != "n/a" + else "" + ), ) ) device_index = click.prompt( diff --git a/platformio/test/reports/json.py b/platformio/test/reports/json.py index 791224c7..3d3c6f6e 100644 --- a/platformio/test/reports/json.py +++ b/platformio/test/reports/json.py @@ -62,11 +62,13 @@ class JsonTestReport(TestReportBase): test_dir=test_suite.test_dir, status=test_suite.status.name, duration=test_suite.duration, - timestamp=datetime.datetime.fromtimestamp(test_suite.timestamp).strftime( - "%Y-%m-%dT%H:%M:%S" - ) - if test_suite.timestamp - else None, + timestamp=( + datetime.datetime.fromtimestamp(test_suite.timestamp).strftime( + "%Y-%m-%dT%H:%M:%S" + ) + if test_suite.timestamp + else None + ), testcase_nums=len(test_suite.cases), error_nums=test_suite.get_status_nums(TestStatus.ERRORED), failure_nums=test_suite.get_status_nums(TestStatus.FAILED),