Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

project: Format and sort imports #765

Merged
merged 3 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/west/app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import argparse

from west.commands import CommandError, WestCommand
from west.configuration import ConfigFile
from west.commands import WestCommand, CommandError

CONFIG_DESCRIPTION = '''\
West configuration file handling.
Expand Down
53 changes: 39 additions & 14 deletions src/west/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,61 @@
'''

import argparse
from collections import OrderedDict
import colorama
from io import StringIO
import logging
import os
from pathlib import Path, PurePath
import platform
import shlex
import shutil
import signal
import sys
from subprocess import CalledProcessError
import tempfile
import textwrap
import traceback
from collections import OrderedDict
from io import StringIO
from pathlib import Path, PurePath
from subprocess import CalledProcessError
from typing import NamedTuple, Optional

from west import log
import colorama

import west.configuration
from west.commands import WestCommand, extension_commands, \
CommandError, ExtensionCommandError, Verbosity
from west.app.project import List, ManifestCommand, Compare, Diff, Status, \
SelfUpdate, ForAll, Grep, Init, Update, Topdir
from west import log
from west.app.config import Config
from west.manifest import Manifest, MalformedConfig, MalformedManifest, \
ManifestVersionError, ManifestImportFailed, _ManifestImportDepth, \
ManifestProject, MANIFEST_REV_BRANCH
from west.util import quote_sh_list, west_topdir, WestNotFound
from west.app.project import (
Compare,
Diff,
ForAll,
Grep,
Init,
List,
ManifestCommand,
SelfUpdate,
Status,
Topdir,
Update,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 per line is a significant waste of screen estate but no big deal...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Splitting these long lines to help out a lot for git diffs though.

)
from west.commands import (
CommandError,
ExtensionCommandError,
Verbosity,
WestCommand,
extension_commands,
)
from west.manifest import (
MANIFEST_REV_BRANCH,
MalformedConfig,
MalformedManifest,
Manifest,
ManifestImportFailed,
ManifestProject,
ManifestVersionError,
_ManifestImportDepth,
)
from west.util import WestNotFound, quote_sh_list, west_topdir
from west.version import __version__


class EarlyArgs(NamedTuple):
# Data type for storing "early" argument parsing results.
#
Expand Down
25 changes: 15 additions & 10 deletions src/west/app/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,35 @@
'''West project commands'''

import argparse
from functools import partial
import logging
import os
from os.path import abspath, relpath
from pathlib import PurePath, Path
import shutil
import shlex
import shutil
import subprocess
import sys
import textwrap
import time
from functools import partial
from os.path import abspath, relpath
from pathlib import Path, PurePath
from time import perf_counter
from urllib.parse import urlparse

from west.configuration import Configuration
from west import util
from west.commands import WestCommand, CommandError, Verbosity
from west.manifest import ImportFlag, Manifest, \
ManifestProject, _manifest_content_at, ManifestImportFailed
from west.manifest import is_group as is_project_group
from west.commands import CommandError, Verbosity, WestCommand
from west.configuration import Configuration
from west.manifest import MANIFEST_REV_BRANCH as MANIFEST_REV
from west.manifest import Submodule
from west.manifest import QUAL_MANIFEST_REV_BRANCH as QUAL_MANIFEST_REV
from west.manifest import QUAL_REFS_WEST as QUAL_REFS
from west.manifest import (
ImportFlag,
Manifest,
ManifestImportFailed,
ManifestProject,
Submodule,
_manifest_content_at,
)
from west.manifest import is_group as is_project_group

#
# Project-related or multi-repo commands, like "init", "update",
Expand Down
12 changes: 6 additions & 6 deletions src/west/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
#
# SPDX-License-Identifier: Apache-2.0

from abc import ABC, abstractmethod
import argparse
from collections import OrderedDict
from dataclasses import dataclass
from enum import IntEnum
import importlib.util
import itertools
import os
from pathlib import Path
import re
import shutil
import subprocess
import sys
from abc import ABC, abstractmethod
from collections import OrderedDict
from dataclasses import dataclass
from enum import IntEnum
from pathlib import Path
from types import ModuleType
from typing import Callable, NoReturn, Optional

Expand All @@ -26,7 +26,7 @@

from west.configuration import Configuration
from west.manifest import Manifest, Project
from west.util import escapes_directory, quote_sh_list, PathType
from west.util import PathType, escapes_directory, quote_sh_list

'''\
This package provides WestCommand, which is the common abstraction all
Expand Down
11 changes: 6 additions & 5 deletions src/west/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@

import configparser
import os
from pathlib import PureWindowsPath, Path
import platform
from enum import Enum
from typing import Any, Optional, TYPE_CHECKING, Union
from collections.abc import Iterable
import warnings
from collections.abc import Iterable
from enum import Enum
from pathlib import Path, PureWindowsPath
from typing import TYPE_CHECKING, Any, Optional, Union

from west.util import WEST_DIR, PathType, WestNotFound, west_dir

from west.util import WEST_DIR, west_dir, WestNotFound, PathType

class MalformedConfig(Exception):
'''The west configuration was malformed.
Expand Down
6 changes: 3 additions & 3 deletions src/west/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
'''

import sys
from typing import NoReturn
import warnings

from west import configuration as config
from typing import NoReturn

import colorama

from west import configuration as config

VERBOSE_NONE = 0
'''Default verbosity level, no dbg() messages printed.'''

Expand Down
11 changes: 5 additions & 6 deletions src/west/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,26 @@
Parser and abstract data types for west manifests.
'''

from collections import deque
import enum
import errno
import logging
import os
from pathlib import PurePosixPath, Path
import re
import shlex
import subprocess
import sys
from typing import Any, Callable, NoReturn, \
NamedTuple, Optional, TYPE_CHECKING, Union
from collections import deque
from collections.abc import Iterable
from pathlib import Path, PurePosixPath
from typing import TYPE_CHECKING, Any, Callable, NamedTuple, NoReturn, Optional, Union

from packaging.version import parse as parse_version
import pykwalify.core
import yaml
from packaging.version import parse as parse_version

from west import util
from west.configuration import ConfigFile, Configuration, MalformedConfig
from west.util import PathType
from west.configuration import Configuration, ConfigFile, MalformedConfig

#
# Public constants
Expand Down