PyLint: Fix "useless-object-inheritance"

This commit is contained in:
Ivan Kravets
2022-07-02 19:03:25 +03:00
parent 19d518fc4c
commit b006f53010
44 changed files with 69 additions and 67 deletions

View File

@ -3,16 +3,10 @@ output-format=colorized
[MESSAGES CONTROL]
disable=
bad-continuation,
bad-whitespace,
missing-docstring,
ungrouped-imports,
invalid-name,
cyclic-import,
duplicate-code,
superfluous-parens,
too-few-public-methods,
useless-object-inheritance,
superfluous-parens,
useless-import-alias,
bad-option-value,
consider-using-dict-items,

View File

@ -70,7 +70,7 @@ SESSION_VARS = {
}
class State(object):
class State:
def __init__(self, path=None, lock=False):
self.path = path
self.lock = lock

View File

@ -26,7 +26,7 @@ import click
from platformio.compat import get_filesystem_encoding, get_locale_encoding
class InoToCPPConverter(object):
class InoToCPPConverter:
PROTOTYPE_RE = re.compile(
r"""^(

View File

@ -46,7 +46,7 @@ from platformio.package.meta import PackageItem
from platformio.project.options import ProjectOptions
class LibBuilderFactory(object):
class LibBuilderFactory:
@staticmethod
def new(env, path, verbose=int(ARGUMENTS.get("PIOVERBOSE", 0))):
clsname = "UnknownLibBuilder"

View File

@ -23,7 +23,7 @@ from platformio.package.lockfile import LockFile
from platformio.project.helpers import get_project_cache_dir
class ContentCache(object):
class ContentCache:
def __init__(self, namespace=None):
self.cache_dir = os.path.join(get_project_cache_dir(), namespace or "content")
self._db_path = os.path.join(self.cache_dir, "db.data")

View File

@ -22,7 +22,7 @@ from platformio.project.helpers import get_project_dir
# pylint: disable=too-many-arguments
class DefectItem(object):
class DefectItem:
SEVERITY_HIGH = 1
SEVERITY_MEDIUM = 2

View File

@ -18,7 +18,7 @@ from platformio.check.tools.cppcheck import CppcheckCheckTool
from platformio.check.tools.pvsstudio import PvsStudioCheckTool
class CheckToolFactory(object):
class CheckToolFactory:
@staticmethod
def new(tool, project_dir, config, envname, options):
cls = None

View File

@ -25,7 +25,7 @@ from platformio.package.meta import PackageSpec
from platformio.project.helpers import load_build_metadata
class CheckToolBase(object): # pylint: disable=too-many-instance-attributes
class CheckToolBase: # pylint: disable=too-many-instance-attributes
def __init__(self, project_dir, config, envname, options):
self.config = config
self.envname = envname

View File

@ -19,7 +19,7 @@ from platformio.debug.config.generic import GenericDebugConfig
from platformio.debug.config.native import NativeDebugConfig
class DebugConfigFactory(object):
class DebugConfigFactory:
@staticmethod
def get_clsname(name):
name = re.sub(r"[^\da-z\_\-]+", "", name, flags=re.I)

View File

@ -84,7 +84,7 @@ def list_logical_devices():
def list_mdns_services():
class mDNSListener(object):
class mDNSListener:
def __init__(self):
self._zc = zeroconf.Zeroconf(interfaces=zeroconf.InterfaceChoice.All)
self._found_types = []

View File

@ -28,7 +28,7 @@ from platformio import exception, proc
from platformio.compat import IS_WINDOWS
class cd(object):
class cd:
def __init__(self, new_path):
self.new_path = new_path
self.prev_path = os.getcwd()

View File

@ -29,7 +29,7 @@ from platformio.compat import get_locale_encoding, is_bytes
from platformio.home import helpers
class MultiThreadingStdStream(object):
class MultiThreadingStdStream:
def __init__(self, parent_stream):
self._buffers = {threading.get_ident(): parent_stream}

View File

@ -57,7 +57,7 @@ class EndpointSession(requests.Session):
return super().request(method, urljoin(self.base_url, url), *args, **kwargs)
class EndpointSessionIterator(object):
class EndpointSessionIterator:
def __init__(self, endpoints):
if not isinstance(endpoints, list):
endpoints = [endpoints]
@ -82,7 +82,7 @@ class EndpointSessionIterator(object):
return session
class HTTPClient(object):
class HTTPClient:
def __init__(self, endpoints):
self._session_iter = EndpointSessionIterator(endpoints)
self._session = None

View File

@ -79,7 +79,7 @@ def set_caller(caller=None):
return app.set_session_var("caller_id", caller)
class Upgrader(object):
class Upgrader:
def __init__(self, from_version, to_version):
self.from_version = pepver_to_semver(from_version)
self.to_version = pepver_to_semver(to_version)

View File

@ -25,7 +25,7 @@ from platformio import __default_requests_timeout__, app, fs
from platformio.package.exception import PackageException
class FileDownloader(object):
class FileDownloader:
def __init__(self, url, dest_dir=None):
self._request = None
# make connection

View File

@ -44,7 +44,7 @@ class LockFileTimeoutError(PlatformioException):
pass
class LockFile(object):
class LockFile:
def __init__(self, path, timeout=LOCKFILE_TIMEOUT, delay=LOCKFILE_DELAY):
self.timeout = timeout
self.delay = delay

View File

@ -25,7 +25,7 @@ from platformio.package.download import FileDownloader
from platformio.package.lockfile import LockFile
class PackageManagerDownloadMixin(object):
class PackageManagerDownloadMixin:
DOWNLOAD_CACHE_EXPIRE = 86400 * 30 # keep package in a local cache for 1 month

View File

@ -26,7 +26,7 @@ from platformio.package.unpack import FileUnpacker
from platformio.package.vcsclient import VCSClientFactory
class PackageManagerInstallMixin(object):
class PackageManagerInstallMixin:
_INSTALL_HISTORY = None # avoid circle dependencies

View File

@ -18,7 +18,7 @@ from platformio import fs
from platformio.package.meta import PackageItem, PackageSpec
class PackageManagerLegacyMixin(object):
class PackageManagerLegacyMixin:
def build_legacy_spec(self, pkg_dir):
# find src manifest
src_manifest_name = ".piopkgmanager.json"

View File

@ -23,7 +23,7 @@ from platformio.registry.client import RegistryClient
from platformio.registry.mirror import RegistryFileMirrorIterator
class PackageManagerRegistryMixin(object):
class PackageManagerRegistryMixin:
def install_from_registry(self, spec, search_qualifiers=None):
if spec.owner and spec.name and not search_qualifiers:
package = self.fetch_registry_package(spec)

View File

@ -20,7 +20,7 @@ from platformio.package.exception import PackageException
from platformio.package.meta import PackageItem, PackageSpec
class PackageManagerSymlinkMixin(object):
class PackageManagerSymlinkMixin:
@staticmethod
def is_symlink(path):
return path and path.endswith(".pio-link") and os.path.isfile(path)

View File

@ -22,7 +22,7 @@ from platformio.package.exception import UnknownPackageError
from platformio.package.meta import PackageItem, PackageSpec
class PackageManagerUninstallMixin(object):
class PackageManagerUninstallMixin:
def uninstall(self, spec, skip_dependencies=False):
try:
self.lock()

View File

@ -21,7 +21,7 @@ from platformio.package.meta import PackageItem, PackageOutdatedResult, PackageS
from platformio.package.vcsclient import VCSBaseException, VCSClientFactory
class PackageManagerUpdateMixin(object):
class PackageManagerUpdateMixin:
def outdated(self, pkg, spec=None):
assert isinstance(pkg, PackageItem)
assert pkg.metadata

View File

@ -27,7 +27,7 @@ from platformio.package.exception import ManifestParserError, UnknownManifestErr
from platformio.project.helpers import is_platformio_project
class ManifestFileType(object):
class ManifestFileType:
PLATFORM_JSON = "platform.json"
LIBRARY_JSON = "library.json"
LIBRARY_PROPERTIES = "library.properties"
@ -53,7 +53,7 @@ class ManifestFileType(object):
return None
class ManifestParserFactory(object):
class ManifestParserFactory:
@staticmethod
def read_manifest_contents(path):
last_err = None
@ -139,7 +139,7 @@ class ManifestParserFactory(object):
raise UnknownManifestError("Unknown manifest file type %s" % type)
class BaseManifestParser(object):
class BaseManifestParser:
def __init__(self, contents, remote_url=None, package_dir=None):
self.remote_url = remote_url
self.package_dir = package_dir

View File

@ -28,7 +28,7 @@ from platformio.util import memoized
class BaseSchema(Schema):
class Meta(object): # pylint: disable=no-init
class Meta: # pylint: disable=no-init
unknown = marshmallow.EXCLUDE # pylint: disable=no-member
def load_manifest(self, data):
@ -253,7 +253,9 @@ class ManifestSchema(BaseSchema):
try:
spdx = self.load_spdx_licenses()
except requests.exceptions.RequestException as exc:
raise ValidationError("Could not load SPDX licenses for validation") from exc
raise ValidationError(
"Could not load SPDX licenses for validation"
) from exc
known_ids = set(item.get("licenseId") for item in spdx.get("licenses", []))
if value in known_ids:
return True

View File

@ -27,7 +27,7 @@ from platformio.package.manifest.parser import ManifestFileType
from platformio.package.version import cast_version_to_semver
class PackageType(object):
class PackageType:
LIBRARY = "library"
PLATFORM = "platform"
TOOL = "tool"
@ -63,7 +63,7 @@ class PackageType(object):
return None
class PackageOutdatedResult(object):
class PackageOutdatedResult:
UPDATE_INCREMENT_MAJOR = "major"
UPDATE_INCREMENT_MINOR = "minor"
UPDATE_INCREMENT_PATCH = "patch"
@ -122,7 +122,7 @@ class PackageOutdatedResult(object):
return True
class PackageSpec(object): # pylint: disable=too-many-instance-attributes
class PackageSpec: # pylint: disable=too-many-instance-attributes
def __init__( # pylint: disable=redefined-builtin,too-many-arguments
self, raw=None, owner=None, id=None, name=None, requirements=None, uri=None
):
@ -358,7 +358,7 @@ class PackageSpec(object): # pylint: disable=too-many-instance-attributes
return name
class PackageMetaData(object):
class PackageMetaData:
def __init__( # pylint: disable=redefined-builtin
self, type, name, version, spec=None
):
@ -426,7 +426,7 @@ class PackageMetaData(object):
return PackageMetaData(**data)
class PackageItem(object):
class PackageItem:
METAFILE_NAME = ".piopm"

View File

@ -32,7 +32,7 @@ from platformio.package.meta import PackageItem
from platformio.package.unpack import FileUnpacker
class PackagePacker(object):
class PackagePacker:
INCLUDE_DEFAULT = list(ManifestFileType.items().values()) + [
"README",
"README.md",

View File

@ -31,7 +31,7 @@ class ExtractArchiveItemError(PackageException):
)
class BaseArchiver(object):
class BaseArchiver:
def __init__(self, arhfileobj):
self._afo = arhfileobj
@ -129,7 +129,7 @@ class ZIPArchiver(BaseArchiver):
self.preserve_mtime(item, dest_dir)
class FileUnpacker(object):
class FileUnpacker:
def __init__(self, path):
self.path = path
self._archiver = None

View File

@ -29,7 +29,7 @@ class VCSBaseException(PackageException):
pass
class VCSClientFactory(object):
class VCSClientFactory:
@staticmethod
def new(src_dir, remote_url, silent=False):
result = urlparse(remote_url)
@ -52,10 +52,12 @@ class VCSClientFactory(object):
assert isinstance(obj, VCSClientBase)
return obj
except (KeyError, AssertionError) as exc:
raise VCSBaseException("VCS: Unknown repository type %s" % remote_url) from exc
raise VCSBaseException(
"VCS: Unknown repository type %s" % remote_url
) from exc
class VCSClientBase(object):
class VCSClientBase:
command = None
@ -109,7 +111,9 @@ class VCSClientBase(object):
subprocess.check_call(args, **kwargs)
return True
except subprocess.CalledProcessError as exc:
raise VCSBaseException("VCS: Could not process command %s" % exc.cmd) from exc
raise VCSBaseException(
"VCS: Could not process command %s" % exc.cmd
) from exc
def get_cmd_output(self, args, **kwargs):
args = [self.command] + args

View File

@ -15,7 +15,7 @@
from platformio.package.meta import PackageSpec
class PlatformPackagesMixin(object):
class PlatformPackagesMixin:
def get_package_spec(self, name, version=None):
return PackageSpec(
owner=self.packages[name].get("owner"),

View File

@ -27,7 +27,7 @@ from platformio.package.manager.core import get_core_package_dir
from platformio.platform.exception import BuildScriptNotFound
class PlatformRunMixin(object):
class PlatformRunMixin:
LINE_ERROR_RE = re.compile(r"(^|\s+)error:?\s+", re.I)

View File

@ -21,7 +21,7 @@ from platformio.exception import UserSideException
from platformio.platform.exception import InvalidBoardManifest
class PlatformBoardConfig(object):
class PlatformBoardConfig:
def __init__(self, manifest_path):
self._id = os.path.basename(manifest_path)[:-5]
assert os.path.isfile(manifest_path)

View File

@ -23,7 +23,7 @@ from platformio.platform import base
from platformio.platform.exception import UnknownPlatform
class PlatformFactory(object):
class PlatformFactory:
@staticmethod
def get_clsname(name):
name = re.sub(r"[^\da-z\_]+", "", name, flags=re.I)

View File

@ -27,7 +27,7 @@ from platformio.compat import (
)
class AsyncPipeBase(object):
class AsyncPipeBase:
def __init__(self):
self._fd_read, self._fd_write = os.pipe()
self._pipe_reader = os.fdopen(

View File

@ -38,7 +38,7 @@ CONFIG_HEADER = """
"""
class ProjectConfigBase(object):
class ProjectConfigBase:
INLINE_COMMENT_RE = re.compile(r"\s+;.*$")
VARTPL_RE = re.compile(r"\$\{([^\.\}\()]+)\.([^\}]+)\}")
@ -352,7 +352,9 @@ class ProjectConfigBase(object):
except click.BadParameter as exc:
if not self.expand_interpolations:
return value
raise exception.ProjectOptionValueError(exc.format_message(), option, section)
raise exception.ProjectOptionValueError(
exc.format_message(), option, section
)
@staticmethod
def cast_to(value, to_type):
@ -394,7 +396,7 @@ class ProjectConfigBase(object):
return True
class ProjectConfigDirsMixin(object):
class ProjectConfigDirsMixin:
def get_optional_dir(self, name):
"""
Deprecated, used by platformio-node-helpers.project.observer.fetchLibDirs

View File

@ -23,7 +23,7 @@ from platformio.proc import where_is_program
from platformio.project.helpers import load_build_metadata
class ProjectGenerator(object):
class ProjectGenerator:
def __init__(self, config, env_name, ide, board_ids=None):
self.config = config
self.project_dir = os.path.dirname(config.path)

View File

@ -24,7 +24,7 @@ from platformio import fs
from platformio.compat import IS_WINDOWS, hashlib_encode_data
class ConfigOption(object): # pylint: disable=too-many-instance-attributes
class ConfigOption: # pylint: disable=too-many-instance-attributes
def __init__(
self,
scope,

View File

@ -21,7 +21,7 @@ from platformio.http import HTTPClient
from platformio.registry.client import RegistryClient
class RegistryFileMirrorIterator(object):
class RegistryFileMirrorIterator:
HTTP_CLIENT_INSTANCES = {}

View File

@ -16,7 +16,7 @@ from twisted.internet import defer # pylint: disable=import-error
from twisted.spread import pb # pylint: disable=import-error
class AsyncCommandBase(object):
class AsyncCommandBase:
MAX_BUFFER_SIZE = 1024 * 1024 # 1Mb

View File

@ -31,7 +31,7 @@ class PROJECT_SYNC_STAGE(constants.Flags):
COMPLETED = constants.FlagConstant()
class ProjectSync(object):
class ProjectSync:
def __init__(self, path):
self.path = path
if not isdir(self.path):

View File

@ -20,7 +20,7 @@ from platformio.test.runners.base import CTX_META_TEST_RUNNING_NAME
# pylint: disable=too-many-instance-attributes
class EnvironmentProcessor(object):
class EnvironmentProcessor:
def __init__( # pylint: disable=too-many-arguments
self,
cmd_ctx,

View File

@ -34,7 +34,7 @@ from platformio.proc import is_ci, is_container
from platformio.project.helpers import is_platformio_project
class TelemetryBase(object):
class TelemetryBase:
def __init__(self):
self._params = {}
@ -198,7 +198,7 @@ class MeasurementProtocol(TelemetryBase):
@util.singleton
class MPDataPusher(object):
class MPDataPusher:
MAX_WORKERS = 5

View File

@ -23,7 +23,7 @@ from platformio.test.result import TestSuite
from platformio.test.runners.base import TestRunnerBase, TestRunnerOptions
class TestRunnerFactory(object):
class TestRunnerFactory:
@staticmethod
def get_clsname(name):
name = re.sub(r"[^\da-z\_\-]+", "", name, flags=re.I)

View File

@ -38,7 +38,7 @@ from platformio.proc import exec_command
get_serialports = get_serial_ports
class memoized(object):
class memoized:
def __init__(self, expire=0):
expire = str(expire)
if expire.isdigit():
@ -65,7 +65,7 @@ class memoized(object):
self.cache.clear()
class throttle(object):
class throttle:
def __init__(self, threshhold):
self.threshhold = threshhold # milliseconds
self.last = 0
@ -97,7 +97,7 @@ class RetryStopException(RetryException):
pass
class retry(object):
class retry:
RetryNextException = RetryNextException
RetryStopException = RetryStopException