Format code with Black 23.1.0

This commit is contained in:
Ivan Kravets
2023-02-02 17:46:03 +02:00
parent 5073313c33
commit 1af508272b
57 changed files with 11 additions and 96 deletions

View File

@ -21,22 +21,18 @@ from platformio.http import HTTPClient, HTTPClientError
class AccountError(PlatformioException):
MESSAGE = "{0}"
class AccountNotAuthorized(AccountError):
MESSAGE = "You are not authorized! Please log in to PlatformIO Account."
class AccountAlreadyAuthorized(AccountError):
MESSAGE = "You are already authorized with {0} account."
class AccountClient(HTTPClient): # pylint:disable=too-many-public-methods
SUMMARY_CACHE_TTL = 60 * 60 * 24 * 7
def __init__(self):

View File

@ -25,7 +25,6 @@ from platformio.compat import get_filesystem_encoding, get_locale_encoding
class InoToCPPConverter:
PROTOTYPE_RE = re.compile(
r"""^(
(?:template\<.*\>\s*)? # template

View File

@ -109,7 +109,6 @@ class LibBuilderFactory:
class LibBuilderBase:
CLASSIC_SCANNER = SCons.Scanner.C.CScanner()
CCONDITIONAL_SCANNER = SCons.Scanner.C.CConditionalScanner()
# Max depth of nested includes:

View File

@ -24,7 +24,6 @@ from platformio.project.helpers import get_project_dir
class DefectItem:
SEVERITY_HIGH = 1
SEVERITY_MEDIUM = 2
SEVERITY_LOW = 4

View File

@ -19,7 +19,6 @@ import click
class PlatformioCLI(click.MultiCommand):
leftover_args = []
def __init__(self, *args, **kwargs):

View File

@ -42,7 +42,7 @@ def cli(query, installed, json_output): # pylint: disable=R0912
grpboards[board["platform"]].append(board)
terminal_width = shutil.get_terminal_size().columns
for (platform, boards) in sorted(grpboards.items()):
for platform, boards in sorted(grpboards.items()):
click.echo("")
click.echo("Platform: ", nl=False)
click.secho(platform, bold=True)

View File

@ -18,7 +18,6 @@ from platformio.device.finder import SerialPortFinder, is_pattern_port
class BlackmagicDebugConfig(DebugConfigBase):
GDB_INIT_SCRIPT = """
define pio_reset_halt_target
set language c

View File

@ -16,7 +16,6 @@ from platformio.debug.config.base import DebugConfigBase
class GenericDebugConfig(DebugConfigBase):
GDB_INIT_SCRIPT = """
define pio_reset_halt_target
monitor reset halt

View File

@ -16,7 +16,6 @@ from platformio.debug.config.base import DebugConfigBase
class JlinkDebugConfig(DebugConfigBase):
GDB_INIT_SCRIPT = """
define pio_reset_halt_target
monitor reset

View File

@ -16,7 +16,6 @@ from platformio.debug.config.base import DebugConfigBase
class MspdebugDebugConfig(DebugConfigBase):
GDB_INIT_SCRIPT = """
define pio_reset_halt_target
end

View File

@ -17,7 +17,6 @@ from platformio.debug.config.base import DebugConfigBase
class NativeDebugConfig(DebugConfigBase):
GDB_INIT_SCRIPT = """
define pio_reset_halt_target
end

View File

@ -16,7 +16,6 @@ from platformio.debug.config.base import DebugConfigBase
class QemuDebugConfig(DebugConfigBase):
GDB_INIT_SCRIPT = """
define pio_reset_halt_target
monitor system_reset

View File

@ -16,7 +16,6 @@ from platformio.debug.config.base import DebugConfigBase
class RenodeDebugConfig(DebugConfigBase):
GDB_INIT_SCRIPT = """
define pio_reset_halt_target
monitor machine Reset

View File

@ -20,7 +20,6 @@ class DebugError(PlatformioException):
class DebugSupportError(DebugError, UserSideException):
MESSAGE = (
"Currently, PlatformIO does not support debugging for `{0}`.\n"
"Please request support at https://github.com/platformio/"

View File

@ -31,7 +31,6 @@ from platformio.test.runners.factory import TestRunnerFactory
class GDBMIConsoleStream(BytesIO): # pylint: disable=too-few-public-methods
STDOUT = sys.stdout
def write(self, text):

View File

@ -53,7 +53,6 @@ class DebugSubprocessProtocol(asyncio.SubprocessProtocol):
class DebugBaseProcess:
STDOUT_CHUNK_SIZE = 2048
LOG_FILE = None

View File

@ -24,7 +24,6 @@ from platformio.debug.process.client import DebugClientProcess
class GDBClientProcess(DebugClientProcess):
PIO_SRC_NAME = ".pioinit"
INIT_COMPLETED_BANNER = "PlatformIO: Initialization completed"

View File

@ -26,7 +26,6 @@ from platformio.proc import where_is_program
class DebugServerProcess(DebugBaseProcess):
STD_BUFFER_SIZE = 1024
def __init__(self, debug_config):

View File

@ -14,7 +14,6 @@
class PlatformioException(Exception):
MESSAGE = None
def __str__(self): # pragma: no cover
@ -26,7 +25,6 @@ class PlatformioException(Exception):
class ReturnErrorCode(PlatformioException):
MESSAGE = "{0}"
@ -35,7 +33,6 @@ class UserSideException(PlatformioException):
class AbortedByUser(UserSideException):
MESSAGE = "Aborted by user"
@ -49,7 +46,6 @@ class InvalidUdevRules(UserSideException):
class MissedUdevRules(InvalidUdevRules):
MESSAGE = (
"Warning! Please install `99-platformio-udev.rules`. \nMore details: "
"https://docs.platformio.org/en/latest/core/installation/udev-rules.html"
@ -57,7 +53,6 @@ class MissedUdevRules(InvalidUdevRules):
class OutdatedUdevRules(InvalidUdevRules):
MESSAGE = (
"Warning! Your `{0}` are outdated. Please update or reinstall them."
"\nMore details: "
@ -71,32 +66,26 @@ class OutdatedUdevRules(InvalidUdevRules):
class GetSerialPortsError(PlatformioException):
MESSAGE = "No implementation for your platform ('{0}') available"
class GetLatestVersionError(PlatformioException):
MESSAGE = "Can not retrieve the latest PlatformIO version"
class InvalidSettingName(UserSideException):
MESSAGE = "Invalid setting with the name '{0}'"
class InvalidSettingValue(UserSideException):
MESSAGE = "Invalid value '{0}' for the setting '{1}'"
class InvalidJSONFile(PlatformioException):
MESSAGE = "Could not load broken JSON: {0}"
class CIBuildEnvsEmpty(UserSideException):
MESSAGE = (
"Can't find PlatformIO build environments.\n"
"Please specify `--board` or path to `platformio.ini` with "
@ -105,7 +94,6 @@ class CIBuildEnvsEmpty(UserSideException):
class UpgradeError(PlatformioException):
MESSAGE = """{0}
* Upgrade using `pip install -U platformio`
@ -115,7 +103,6 @@ class UpgradeError(PlatformioException):
class HomeDirPermissionsError(UserSideException):
MESSAGE = (
"The directory `{0}` or its parent directory is not owned by the "
"current user and PlatformIO can not store configuration data.\n"
@ -126,7 +113,6 @@ class HomeDirPermissionsError(UserSideException):
class CygwinEnvDetected(PlatformioException):
MESSAGE = (
"PlatformIO does not work within Cygwin environment. "
"Use native Terminal instead."

View File

@ -181,7 +181,7 @@ def match_src_files(src_dir, src_filter=None, src_exts=None, followlinks=True):
result = set()
# correct fs directory separator
src_filter = src_filter.replace("/", os.sep).replace("\\", os.sep)
for (action, pattern) in re.findall(r"(\+|\-)<([^>]+)>", src_filter):
for action, pattern in re.findall(r"(\+|\-)<([^>]+)>", src_filter):
candidates = _find_candidates(pattern)
if action == "+":
result |= candidates

View File

@ -21,7 +21,6 @@ from platformio.project.helpers import is_platformio_project
class AppRPC:
IGNORE_STORAGE_KEYS = [
"cid",
"coreVersion",

View File

@ -21,7 +21,6 @@ from platformio.compat import aio_get_running_loop
class IDERPC:
COMMAND_TIMEOUT = 1.5 # in seconds
def __init__(self):

View File

@ -24,8 +24,8 @@ from starlette.concurrency import run_in_threadpool
from platformio import __main__, __version__, fs, proc
from platformio.compat import get_locale_encoding, is_bytes
from platformio.home import helpers
from platformio.exception import PlatformioException
from platformio.home import helpers
class MultiThreadingStdStream:

View File

@ -24,7 +24,6 @@ from platformio.proc import force_exit
class JSONRPCServerFactoryBase:
connection_nums = 0
shutdown_timer = None

View File

@ -38,7 +38,6 @@ class HTTPClientError(PlatformioException):
class InternetConnectionError(UserSideException):
MESSAGE = (
"You are not connected to the Internet.\n"
"PlatformIO needs the Internet connection to"

View File

@ -137,7 +137,7 @@ def list_global_packages(options):
only_packages = any(
options.get(type_) or options.get(f"only_{type_}") for (type_, _) in data
)
for (type_, pm) in data:
for type_, pm in data:
skip_conds = [
only_packages
and not options.get(type_)

View File

@ -48,12 +48,10 @@ class ManifestValidationError(ManifestException):
class MissingPackageManifestError(ManifestException):
MESSAGE = "Could not find one of '{0}' manifest files in the package"
class UnknownPackageError(UserSideException):
MESSAGE = (
"Could not find the package with '{0}' requirements for your system '%s'"
% util.get_systype()
@ -61,7 +59,6 @@ class UnknownPackageError(UserSideException):
class NotGlobalLibDir(UserSideException):
MESSAGE = (
"The `{0}` is not a PlatformIO project.\n\n"
"To manage libraries in global storage `{1}`,\n"

View File

@ -26,7 +26,6 @@ from platformio.package.lockfile import LockFile
class PackageManagerDownloadMixin:
DOWNLOAD_CACHE_EXPIRE = 86400 * 30 # keep package in a local cache for 1 month
def compute_download_path(self, *args):

View File

@ -27,7 +27,6 @@ from platformio.package.vcsclient import VCSClientFactory
class PackageManagerInstallMixin:
_INSTALL_HISTORY = None # avoid circle dependencies
@staticmethod

View File

@ -65,7 +65,6 @@ class PackageType:
class PackageCompatibility:
KNOWN_QUALIFIERS = ("platforms", "frameworks", "authors")
@classmethod
@ -468,7 +467,6 @@ class PackageMetaData:
class PackageItem:
METAFILE_NAME = ".piopm"
def __init__(self, path, metadata=None):

View File

@ -24,7 +24,6 @@ from platformio.package.exception import PackageException
class ExtractArchiveItemError(PackageException):
MESSAGE = (
"Could not extract `{0}` to `{1}`. Try to disable antivirus "
"tool or check this solution -> https://bit.ly/faq-package-manager"

View File

@ -58,7 +58,6 @@ class VCSClientFactory:
class VCSClientBase:
command = None
def __init__(self, src_dir, remote_url=None, tag=None, silent=False):
@ -128,7 +127,6 @@ class VCSClientBase:
class GitClient(VCSClientBase):
command = "git"
_configured = False
@ -232,7 +230,6 @@ class GitClient(VCSClientBase):
class HgClient(VCSClientBase):
command = "hg"
def export(self):
@ -256,7 +253,6 @@ class HgClient(VCSClientBase):
class SvnClient(VCSClientBase):
command = "svn"
def export(self):

View File

@ -28,7 +28,6 @@ from platformio.platform.exception import BuildScriptNotFound
class PlatformRunMixin:
LINE_ERROR_RE = re.compile(r"(^|\s+)error:?\s+", re.I)
@staticmethod

View File

@ -29,7 +29,6 @@ from platformio.project.config import ProjectConfig
class PlatformBase( # pylint: disable=too-many-instance-attributes,too-many-public-methods
PlatformPackagesMixin, PlatformRunMixin
):
CORE_SEMVER = pepver_to_semver(__version__)
_BOARDS_CACHE = {}

View File

@ -20,12 +20,10 @@ class PlatformException(PlatformioException):
class UnknownPlatform(PlatformException):
MESSAGE = "Unknown development platform '{0}'"
class IncompatiblePlatform(PlatformException):
MESSAGE = (
"Development platform '{0}' is not compatible with PlatformIO Core v{1} and "
"depends on PlatformIO Core {2}.\n"
@ -33,20 +31,16 @@ class IncompatiblePlatform(PlatformException):
class UnknownBoard(PlatformException):
MESSAGE = "Unknown board ID '{0}'"
class InvalidBoardManifest(PlatformException):
MESSAGE = "Invalid board JSON manifest '{0}'"
class UnknownFramework(PlatformException):
MESSAGE = "Unknown framework '{0}'"
class BuildScriptNotFound(PlatformException):
MESSAGE = "Invalid path '{0}' to build script"

View File

@ -166,7 +166,7 @@ def init_base_project(project_dir):
(config.get("platformio", "lib_dir"), init_lib_readme),
(config.get("platformio", "test_dir"), init_test_readme),
]
for (path, cb) in dir_to_readme:
for path, cb in dir_to_readme:
if os.path.isdir(path):
continue
os.makedirs(path)

View File

@ -39,7 +39,6 @@ CONFIG_HEADER = """
class ProjectConfigBase:
INLINE_COMMENT_RE = re.compile(r"\s+;.*$")
VARTPL_RE = re.compile(r"\$\{([^\.\}\()]+)\.([^\}]+)\}")
@ -412,7 +411,6 @@ class ProjectConfigDirsMixin:
class ProjectConfig(ProjectConfigBase, ProjectConfigDirsMixin):
_instances = {}
@staticmethod

View File

@ -20,7 +20,6 @@ class ProjectError(PlatformioException):
class NotPlatformIOProjectError(ProjectError, UserSideException):
MESSAGE = (
"Not a PlatformIO project. `platformio.ini` file has not been "
"found in current working directory ({0}). To initialize new project "
@ -29,25 +28,20 @@ class NotPlatformIOProjectError(ProjectError, UserSideException):
class InvalidProjectConfError(ProjectError, UserSideException):
MESSAGE = "Invalid '{0}' (project configuration file): '{1}'"
class UndefinedEnvPlatformError(ProjectError, UserSideException):
MESSAGE = "Please specify platform for '{0}' environment"
class ProjectEnvsNotAvailableError(ProjectError, UserSideException):
MESSAGE = "Please setup environments in `platformio.ini` file"
class UnknownEnvNamesError(ProjectError, UserSideException):
MESSAGE = "Unknown environment names '{0}'. Valid names are '{1}'"
class ProjectOptionValueError(ProjectError, UserSideException):
MESSAGE = "{0} for option `{1}` in section [{2}]"

View File

@ -22,7 +22,6 @@ from platformio.registry.client import RegistryClient
class RegistryFileMirrorIterator:
HTTP_CLIENT_INSTANCES = {}
def __init__(self, download_url):

View File

@ -17,7 +17,6 @@ from twisted.spread import pb # pylint: disable=import-error
class AsyncCommandBase:
MAX_BUFFER_SIZE = 1024 * 1024 # 1Mb
def __init__(self, options=None, on_end_callback=None):

View File

@ -118,7 +118,6 @@ def remote_run(
silent,
verbose,
):
from platformio.remote.client.run_or_test import RunOrTestClient
cr = RunOrTestClient(
@ -211,7 +210,6 @@ def remote_test( # pylint: disable=redefined-builtin
without_uploading,
verbose,
):
from platformio.remote.client.run_or_test import RunOrTestClient
cr = RunOrTestClient(

View File

@ -34,7 +34,7 @@ class AsyncClientBase(RemoteClientBase):
def cb_async_result(self, result):
if self._acs_total == 0:
self._acs_total = len(result)
for (success, value) in result:
for success, value in result:
if not success:
raise pb.Error(value)
self.acread_data(*value)

View File

@ -33,7 +33,6 @@ from platformio.remote.factory.ssl import SSLContextFactory
class RemoteClientBase( # pylint: disable=too-many-instance-attributes
pb.Referenceable
):
PING_DELAY = 60
PING_MAX_FAILURES = 3
DEBUG = False

View File

@ -32,7 +32,7 @@ class DeviceListClient(RemoteClientBase):
def _cbResult(self, result):
data = {}
for (success, value) in result:
for success, value in result:
if not success:
click.secho(value, fg="red", err=True)
continue

View File

@ -71,7 +71,6 @@ class SMBridgeFactory(protocol.ServerFactory):
class DeviceMonitorClient( # pylint: disable=too-many-instance-attributes
RemoteClientBase
):
MAX_BUFFER_SIZE = 1024 * 1024
def __init__(self, agents, **kwargs):
@ -96,7 +95,7 @@ class DeviceMonitorClient( # pylint: disable=too-many-instance-attributes
def _cb_device_list(self, result):
devices = []
hwid_devindexes = []
for (success, value) in result:
for success, value in result:
if not success:
click.secho(value, fg="red", err=True)
continue

View File

@ -28,7 +28,6 @@ from platformio.remote.projectsync import PROJECT_SYNC_STAGE, ProjectSync
class RunOrTestClient(AsyncClientBase):
MAX_ARCHIVE_SIZE = 50 * 1024 * 1024 # 50Mb
UPLOAD_CHUNK_SIZE = 256 * 1024 # 256Kb
@ -147,7 +146,7 @@ class RunOrTestClient(AsyncClientBase):
def cb_psync_init_result(self, result):
self._acs_total = len(result)
for (success, value) in result:
for success, value in result:
if not success:
raise pb.Error(value)
agent_id, ac_id = value

View File

@ -47,13 +47,13 @@ class ProjectSync:
def rebuild_dbindex(self):
self._db = {}
for (path, relpath, cb_filter) in self.items:
for path, relpath, cb_filter in self.items:
if cb_filter and not cb_filter(path):
continue
self._insert_to_db(path, relpath)
if not isdir(path):
continue
for (root, _, files) in os.walk(path, followlinks=True):
for root, _, files in os.walk(path, followlinks=True):
for name in files:
self._insert_to_db(
join(root, name), join(relpath, root[len(path) + 1 :], name)

View File

@ -54,7 +54,6 @@ class TelemetryBase:
class MeasurementProtocol(TelemetryBase):
TID = "UA-1768265-9"
PARAMS_MAP = {
"screen_name": "cd",
@ -201,7 +200,6 @@ class MeasurementProtocol(TelemetryBase):
@util.singleton
class MPDataPusher:
MAX_WORKERS = 5
def __init__(self):

View File

@ -20,7 +20,6 @@ class UnitTestError(PlatformioException):
class TestDirNotExistsError(UnitTestError, UserSideException):
MESSAGE = (
"A test folder '{0}' does not exist.\nPlease create 'test' "
"directory in the project root and put a test suite.\n"

View File

@ -40,7 +40,6 @@ def list_test_suites(project_config, environments, filters, ignores):
test_names = list_test_names(project_config)
for env_name in project_config.envs():
for test_name in test_names:
# filter and ignore patterns
patterns = dict(filter=list(filters), ignore=list(ignores))
for key, value in patterns.items():

View File

@ -54,7 +54,6 @@ class TestRunnerOptions: # pylint: disable=too-many-instance-attributes
class TestRunnerBase:
NAME = None
EXTRA_LIB_DEPS = None
TESTCASE_PARSE_RE = None

View File

@ -101,7 +101,6 @@ class DoctestTestCaseParser:
class DoctestTestRunner(TestRunnerBase):
EXTRA_LIB_DEPS = ["doctest/doctest@^2.4.9"]
def __init__(self, *args, **kwargs):

View File

@ -22,7 +22,6 @@ from platformio.test.runners.base import TestRunnerBase
class GoogletestTestCaseParser:
# Examples:
# [ RUN ] FooTest.Bar
# ...
@ -89,7 +88,6 @@ class GoogletestTestCaseParser:
class GoogletestTestRunner(TestRunnerBase):
EXTRA_LIB_DEPS = ["google/googletest@^1.12.1"]
def __init__(self, *args, **kwargs):

View File

@ -22,7 +22,6 @@ from platformio.exception import UserSideException
class SerialTestOutputReader:
SERIAL_TIMEOUT = 600
def __init__(self, test_runner):

View File

@ -26,7 +26,6 @@ from platformio.util import strip_ansi_codes
class UnityTestRunner(TestRunnerBase):
EXTRA_LIB_DEPS = ["throwtheswitch/Unity@^2.5.2"]
# Examples:

View File

@ -96,7 +96,6 @@ class RetryStopException(RetryException):
class retry:
RetryNextException = RetryNextException
RetryStopException = RetryStopException

View File

@ -112,7 +112,6 @@ def test_ci_keep_build_dir_single_src_dir(
def test_ci_keep_build_dir_nested_src_dirs(
clirunner, tmpdir_factory, validate_cliresult
):
build_dir = str(tmpdir_factory.mktemp("ci_build_dir"))
# Split default Arduino project in two parts