forked from platformio/platformio-core
Disable PyLint's "import-outside-toplevel"
This commit is contained in:
@ -25,11 +25,8 @@ import requests
|
||||
from platformio import exception, fs, lockfile
|
||||
from platformio.compat import WINDOWS, dump_json_to_unicode, hashlib_encode_data
|
||||
from platformio.proc import is_ci
|
||||
from platformio.project.helpers import (
|
||||
get_default_projects_dir,
|
||||
get_project_cache_dir,
|
||||
get_project_core_dir,
|
||||
)
|
||||
from platformio.project.helpers import (get_default_projects_dir, get_project_cache_dir,
|
||||
get_project_core_dir)
|
||||
|
||||
|
||||
def projects_dir_validate(projects_dir):
|
||||
|
@ -58,14 +58,12 @@ class PlatformioCLI(click.MultiCommand):
|
||||
try:
|
||||
mod = __import__("platformio.commands." + cmd_name, None, None, ["cli"])
|
||||
except ImportError:
|
||||
try:
|
||||
return self._handle_obsolate_command(cmd_name)
|
||||
except AttributeError:
|
||||
raise click.UsageError('No such command "%s"' % cmd_name, ctx)
|
||||
raise click.UsageError('No such command "%s"' % cmd_name, ctx)
|
||||
return mod.cli
|
||||
|
||||
@staticmethod
|
||||
def _handle_obsolate_command(name):
|
||||
# pylint: disable=import-outside-toplevel
|
||||
if name == "platforms":
|
||||
from platformio.commands import platform
|
||||
|
||||
|
@ -137,6 +137,8 @@ def cli(ctx, project_dir, project_conf, environment, verbose, interface, __unpro
|
||||
|
||||
# run debugging client
|
||||
inject_contrib_pysite()
|
||||
|
||||
# pylint: disable=import-outside-toplevel
|
||||
from platformio.debug.client import GDBClient, reactor
|
||||
|
||||
client = GDBClient(project_dir, __unprocessed, debug_options, env_options)
|
||||
|
@ -36,14 +36,14 @@ from platformio.managers.core import get_core_package_dir, inject_contrib_pysite
|
||||
)
|
||||
@click.option("--no-open", is_flag=True)
|
||||
def cli(port, host, no_open):
|
||||
# pylint: disable=import-error, import-outside-toplevel
|
||||
|
||||
# import contrib modules
|
||||
inject_contrib_pysite()
|
||||
# pylint: disable=import-error
|
||||
from autobahn.twisted.resource import WebSocketResource
|
||||
from twisted.internet import reactor
|
||||
from twisted.web import server
|
||||
|
||||
# pylint: enable=import-error
|
||||
from platformio.home.rpc.handlers.app import AppRPC
|
||||
from platformio.home.rpc.handlers.ide import IDERPC
|
||||
from platformio.home.rpc.handlers.misc import MiscRPC
|
||||
|
@ -93,7 +93,7 @@ def format_filesize(filesize):
|
||||
|
||||
|
||||
def ensure_udev_rules():
|
||||
from platformio.util import get_systype
|
||||
from platformio.util import get_systype # pylint: disable=import-outside-toplevel
|
||||
|
||||
def _rules_to_set(rules_path):
|
||||
return set(
|
||||
|
@ -103,7 +103,7 @@ def update_core_packages(only_check=False, silent=False):
|
||||
|
||||
|
||||
def inject_contrib_pysite():
|
||||
from site import addsitedir
|
||||
from site import addsitedir # pylint: disable=import-outside-toplevel
|
||||
|
||||
contrib_pysite_dir = get_core_package_dir("contrib-pysite")
|
||||
if contrib_pysite_dir in sys.path:
|
||||
|
@ -264,6 +264,7 @@ class LibraryManager(BasePkgManager):
|
||||
fg="yellow",
|
||||
err=True,
|
||||
)
|
||||
# pylint: disable=import-outside-toplevel
|
||||
from platformio.commands.lib import print_lib_item
|
||||
|
||||
for item in result["items"]:
|
||||
|
@ -27,12 +27,8 @@ from platformio import __version__, app, exception, fs, util
|
||||
from platformio.compat import PY2, hashlib_encode_data, is_bytes, load_python_module
|
||||
from platformio.managers.core import get_core_package_dir
|
||||
from platformio.managers.package import BasePkgManager, PackageManager
|
||||
from platformio.proc import (
|
||||
BuildAsyncPipe,
|
||||
copy_pythonpath_to_osenv,
|
||||
exec_command,
|
||||
get_pythonexe_path,
|
||||
)
|
||||
from platformio.proc import (BuildAsyncPipe, copy_pythonpath_to_osenv, exec_command,
|
||||
get_pythonexe_path)
|
||||
from platformio.project.config import ProjectConfig
|
||||
|
||||
try:
|
||||
|
@ -72,7 +72,7 @@ class ProjectConfigBase(object):
|
||||
|
||||
@staticmethod
|
||||
def get_default_path():
|
||||
from platformio import app
|
||||
from platformio import app # pylint: disable=import-outside-toplevel
|
||||
|
||||
return app.get_session_var("custom_project_conf") or os.path.join(
|
||||
os.getcwd(), "platformio.ini"
|
||||
|
@ -136,6 +136,7 @@ def compute_project_checksum(config):
|
||||
|
||||
|
||||
def load_project_ide_data(project_dir, env_or_envs):
|
||||
# pylint: disable=import-outside-toplevel
|
||||
from platformio.commands.run import cli as cmd_run
|
||||
|
||||
assert env_or_envs
|
||||
|
@ -112,6 +112,7 @@ class TestProcessorBase(object):
|
||||
self.cmd_ctx.meta[CTX_META_TEST_RUNNING_NAME] = self.test_name
|
||||
|
||||
try:
|
||||
# pylint: disable=import-outside-toplevel
|
||||
from platformio.commands.run import cli as cmd_run
|
||||
|
||||
return self.cmd_ctx.invoke(
|
||||
|
@ -126,6 +126,7 @@ def change_filemtime(path, mtime):
|
||||
|
||||
def get_serial_ports(filter_hwid=False):
|
||||
try:
|
||||
# pylint: disable=import-outside-toplevel
|
||||
from serial.tools.list_ports import comports
|
||||
except ImportError:
|
||||
raise exception.GetSerialPortsError(os.name)
|
||||
@ -190,8 +191,9 @@ def get_logical_devices():
|
||||
|
||||
|
||||
def get_mdns_services():
|
||||
# pylint: disable=import-outside-toplevel
|
||||
try:
|
||||
import zeroconf # pylint: disable=import-outside-toplevel
|
||||
import zeroconf
|
||||
except ImportError:
|
||||
from site import addsitedir
|
||||
from platformio.managers.core import get_core_package_dir
|
||||
@ -282,7 +284,7 @@ def _api_request_session():
|
||||
def _get_api_result(
|
||||
url, params=None, data=None, auth=None # pylint: disable=too-many-branches
|
||||
):
|
||||
from platformio.app import get_setting
|
||||
from platformio.app import get_setting # pylint: disable=import-outside-toplevel
|
||||
|
||||
result = {}
|
||||
r = None
|
||||
@ -326,7 +328,7 @@ def _get_api_result(
|
||||
|
||||
|
||||
def get_api_result(url, params=None, data=None, auth=None, cache_valid=None):
|
||||
from platformio.app import ContentCache
|
||||
from platformio.app import ContentCache # pylint: disable=import-outside-toplevel
|
||||
|
||||
total = 0
|
||||
max_retries = 5
|
||||
|
Reference in New Issue
Block a user