forked from platformio/platformio-core
Use PY3 super() zero-argument syntax
This commit is contained in:
1 parent
eaff7f307c
commit
5a0a215bfc
35 files changed
+67
-79
No files matched your search
@@ -34,7 +34,7 @@ class ManifestParserError(ManifestException):
|
||||
|
||||
class ManifestValidationError(ManifestException):
|
||||
def __init__(self, messages, data, valid_data):
|
||||
super(ManifestValidationError, self).__init__()
|
||||
super().__init__()
|
||||
self.messages = messages
|
||||
self.data = data
|
||||
self.valid_data = valid_data
|
||||
|
||||
@@ -64,7 +64,7 @@ class PackageManagerInstallMixin(object):
|
||||
# avoid circle dependencies
|
||||
if not self._INSTALL_HISTORY:
|
||||
self._INSTALL_HISTORY = {}
|
||||
if spec in self._INSTALL_HISTORY:
|
||||
if not force and spec in self._INSTALL_HISTORY:
|
||||
return self._INSTALL_HISTORY[spec]
|
||||
|
||||
# check if package is already installed
|
||||
|
||||
@@ -24,7 +24,7 @@ from platformio.project.config import ProjectConfig
|
||||
|
||||
class LibraryPackageManager(BasePackageManager): # pylint: disable=too-many-ancestors
|
||||
def __init__(self, package_dir=None):
|
||||
super(LibraryPackageManager, self).__init__(
|
||||
super().__init__(
|
||||
PackageType.LIBRARY,
|
||||
package_dir
|
||||
or ProjectConfig.get_instance().get("platformio", "globallib_dir"),
|
||||
@@ -36,7 +36,7 @@ class LibraryPackageManager(BasePackageManager): # pylint: disable=too-many-anc
|
||||
|
||||
def find_pkg_root(self, path, spec):
|
||||
try:
|
||||
return super(LibraryPackageManager, self).find_pkg_root(path, spec)
|
||||
return super().find_pkg_root(path, spec)
|
||||
except MissingPackageManifestError:
|
||||
pass
|
||||
assert isinstance(spec, PackageSpec)
|
||||
@@ -86,5 +86,5 @@ class LibraryPackageManager(BasePackageManager): # pylint: disable=too-many-anc
|
||||
if not any(not_builtin_conds):
|
||||
not_builtin_conds.append(not is_builtin_lib(spec.name))
|
||||
if any(not_builtin_conds):
|
||||
return super(LibraryPackageManager, self).install_dependency(dependency)
|
||||
return super().install_dependency(dependency)
|
||||
return None
|
||||
@@ -29,7 +29,7 @@ from platformio.project.config import ProjectConfig
|
||||
class PlatformPackageManager(BasePackageManager): # pylint: disable=too-many-ancestors
|
||||
def __init__(self, package_dir=None):
|
||||
self.config = ProjectConfig.get_instance()
|
||||
super(PlatformPackageManager, self).__init__(
|
||||
super().__init__(
|
||||
PackageType.PLATFORM,
|
||||
package_dir or self.config.get("platformio", "platforms_dir"),
|
||||
)
|
||||
@@ -47,16 +47,14 @@ class PlatformPackageManager(BasePackageManager): # pylint: disable=too-many-an
|
||||
project_targets=None,
|
||||
):
|
||||
already_installed = self.get_package(spec)
|
||||
pkg = super(PlatformPackageManager, self).install(
|
||||
spec, force=force, skip_dependencies=True
|
||||
)
|
||||
pkg = super().install(spec, force=force, skip_dependencies=True)
|
||||
try:
|
||||
p = PlatformFactory.new(pkg)
|
||||
# set logging level for underlying tool manager
|
||||
p.pm.set_log_level(self.log.getEffectiveLevel())
|
||||
p.ensure_engine_compatible()
|
||||
except IncompatiblePlatform as e:
|
||||
super(PlatformPackageManager, self).uninstall(pkg, skip_dependencies=True)
|
||||
super().uninstall(pkg, skip_dependencies=True)
|
||||
raise e
|
||||
if project_env:
|
||||
p.configure_project_packages(project_env, project_targets)
|
||||
@@ -79,9 +77,7 @@ class PlatformPackageManager(BasePackageManager): # pylint: disable=too-many-an
|
||||
p.configure_project_packages(project_env)
|
||||
if not skip_dependencies:
|
||||
p.uninstall_packages()
|
||||
assert super(PlatformPackageManager, self).uninstall(
|
||||
pkg, skip_dependencies=True
|
||||
)
|
||||
assert super().uninstall(pkg, skip_dependencies=True)
|
||||
p.on_uninstalled()
|
||||
return pkg
|
||||
|
||||
@@ -95,7 +91,7 @@ class PlatformPackageManager(BasePackageManager): # pylint: disable=too-many-an
|
||||
pkg = self.get_package(from_spec)
|
||||
if not pkg or not pkg.metadata:
|
||||
raise UnknownPackageError(from_spec)
|
||||
pkg = super(PlatformPackageManager, self).update(
|
||||
pkg = super().update(
|
||||
from_spec,
|
||||
to_spec,
|
||||
)
|
||||
|
||||
@@ -19,9 +19,11 @@ from platformio.project.config import ProjectConfig
|
||||
|
||||
class ToolPackageManager(BasePackageManager): # pylint: disable=too-many-ancestors
|
||||
def __init__(self, package_dir=None):
|
||||
if not package_dir:
|
||||
package_dir = ProjectConfig.get_instance().get("platformio", "packages_dir")
|
||||
super(ToolPackageManager, self).__init__(PackageType.TOOL, package_dir)
|
||||
super().__init__(
|
||||
PackageType.TOOL,
|
||||
package_dir
|
||||
or ProjectConfig.get_instance().get("platformio", "packages_dir"),
|
||||
)
|
||||
|
||||
@property
|
||||
def manifest_names(self):
|
||||
|
||||
@@ -59,9 +59,7 @@ class StrictListField(fields.List):
|
||||
self, value, attr, data, **kwargs
|
||||
):
|
||||
try:
|
||||
return super(StrictListField, self)._deserialize(
|
||||
value, attr, data, **kwargs
|
||||
)
|
||||
return super()._deserialize(value, attr, data, **kwargs)
|
||||
except ValidationError as exc:
|
||||
if exc.data:
|
||||
exc.data = [item for item in exc.data if item is not None]
|
||||
|
||||
@@ -91,7 +91,7 @@ class PackageOutdatedResult(object):
|
||||
and not isinstance(value, semantic_version.Version)
|
||||
):
|
||||
value = cast_version_to_semver(str(value))
|
||||
return super(PackageOutdatedResult, self).__setattr__(name, value)
|
||||
return super().__setattr__(name, value)
|
||||
|
||||
@property
|
||||
def update_increment_type(self):
|
||||
|
||||
@@ -57,9 +57,7 @@ class BaseArchiver(object):
|
||||
|
||||
class TARArchiver(BaseArchiver):
|
||||
def __init__(self, archpath):
|
||||
super(TARArchiver, self).__init__(
|
||||
tarfile_open(archpath) # pylint: disable=consider-using-with
|
||||
)
|
||||
super().__init__(tarfile_open(archpath)) # pylint: disable=consider-using-with
|
||||
|
||||
def get_items(self):
|
||||
return self._afo.getmembers()
|
||||
@@ -90,7 +88,7 @@ class TARArchiver(BaseArchiver):
|
||||
self.is_link(item) and self.is_bad_link(item, dest_dir),
|
||||
]
|
||||
if not any(bad_conds):
|
||||
super(TARArchiver, self).extract_item(item, dest_dir)
|
||||
super().extract_item(item, dest_dir)
|
||||
else:
|
||||
click.secho(
|
||||
"Blocked insecure item `%s` from TAR archive" % item.name,
|
||||
@@ -101,9 +99,7 @@ class TARArchiver(BaseArchiver):
|
||||
|
||||
class ZIPArchiver(BaseArchiver):
|
||||
def __init__(self, archpath):
|
||||
super(ZIPArchiver, self).__init__(
|
||||
ZipFile(archpath) # pylint: disable=consider-using-with
|
||||
)
|
||||
super().__init__(ZipFile(archpath)) # pylint: disable=consider-using-with
|
||||
|
||||
@staticmethod
|
||||
def preserve_permissions(item, dest_dir):
|
||||
|
||||
@@ -131,7 +131,7 @@ class GitClient(VCSClientBase):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.configure()
|
||||
super(GitClient, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
@classmethod
|
||||
def configure(cls):
|
||||
|
||||
Reference in new issue
Block a user