diff --git a/.github/workflows/test-lint-black.yaml b/.github/workflows/test-lint-black.yaml index f62cf41..8e71246 100644 --- a/.github/workflows/test-lint-black.yaml +++ b/.github/workflows/test-lint-black.yaml @@ -1,13 +1,26 @@ -name: Tests | Lint w/ Black +name: Tests | Lint (black, ruff) on: [push, pull_request] +permissions: + contents: read + jobs: + # `lint` is a required check: keep the job name lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + persist-credentials: false + - uses: psf/black@stable with: options: "--check --verbose" version: "23.3.0" + + # Rules and exclusions come from [tool.ruff] in pyproject.toml. Keep the version in sync + # with the dev dependency and the pre-commit hook. + - uses: astral-sh/ruff-action@278981a28ce3188b1e39527901f38254bf3aac89 # v4.1.0 + with: + version: "0.17.5" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b61ef42..5a853f0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,3 +8,7 @@ repos: # pre-commit's default_language_version, see # https://pre-commit.com/#top_level-default_language_version language_version: python3.10 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.17.5 + hooks: + - id: ruff-check diff --git a/.pylintrc b/.pylintrc deleted file mode 100644 index 5e70d2b..0000000 --- a/.pylintrc +++ /dev/null @@ -1,609 +0,0 @@ -[MASTER] - -# A comma-separated list of package or module names from where C extensions may -# be loaded. Extensions are loading into the active Python interpreter and may -# run arbitrary code. -extension-pkg-allow-list= - -# A comma-separated list of package or module names from where C extensions may -# be loaded. Extensions are loading into the active Python interpreter and may -# run arbitrary code. (This is an alternative name to extension-pkg-allow-list -# for backward compatibility.) -extension-pkg-whitelist= - -# Specify a score threshold to be exceeded before program exits with error. -fail-under=10.0 - -# Files or directories to be skipped. They should be base names, not paths. -ignore=CVS - -# Files or directories matching the regex patterns are skipped. The regex -# matches against base names, not paths. -ignore-patterns= - -# Python code to execute, usually for sys.path manipulation such as -# pygtk.require(). -#init-hook= - -# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the -# number of processors available to use. -jobs=1 - -# Control the amount of potential inferred values when inferring a single -# object. This can help the performance when dealing with large functions or -# complex, nested conditions. -limit-inference-results=100 - -# List of plugins (as comma separated values of python module names) to load, -# usually to register additional checkers. -load-plugins= - -# Pickle collected data for later comparisons. -persistent=yes - -# When enabled, pylint would attempt to guess common misconfiguration and emit -# user-friendly hints instead of false-positive error messages. -suggestion-mode=yes - -# Allow loading of arbitrary C extensions. Extensions are imported into the -# active Python interpreter and may run arbitrary code. -unsafe-load-any-extension=no - - -[MESSAGES CONTROL] - -# Only show warnings with the listed confidence levels. Leave empty to show -# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED. -confidence= - -# Disable the message, report, category or checker with the given id(s). You -# can either give multiple identifiers separated by comma (,) or put this -# option multiple times (only on the command line, not in the configuration -# file where it should appear only once). You can also use "--disable=all" to -# disable everything first and then reenable specific checks. For example, if -# you want to run only the similarities checker, you can use "--disable=all -# --enable=similarities". If you want to run only the classes checker, but have -# no Warning level messages displayed, use "--disable=all --enable=classes -# --disable=W". -disable=print-statement, - parameter-unpacking, - unpacking-in-except, - old-raise-syntax, - backtick, - long-suffix, - old-ne-operator, - old-octal-literal, - import-star-module-level, - non-ascii-bytes-literal, - raw-checker-failed, - bad-inline-option, - locally-disabled, - file-ignored, - suppressed-message, - useless-suppression, - deprecated-pragma, - use-symbolic-message-instead, - apply-builtin, - basestring-builtin, - buffer-builtin, - cmp-builtin, - coerce-builtin, - execfile-builtin, - file-builtin, - long-builtin, - raw_input-builtin, - reduce-builtin, - standarderror-builtin, - unicode-builtin, - xrange-builtin, - coerce-method, - delslice-method, - getslice-method, - setslice-method, - no-absolute-import, - old-division, - dict-iter-method, - dict-view-method, - next-method-called, - metaclass-assignment, - indexing-exception, - raising-string, - reload-builtin, - oct-method, - hex-method, - nonzero-method, - cmp-method, - input-builtin, - round-builtin, - intern-builtin, - unichr-builtin, - map-builtin-not-iterating, - zip-builtin-not-iterating, - range-builtin-not-iterating, - filter-builtin-not-iterating, - using-cmp-argument, - eq-without-hash, - div-method, - idiv-method, - rdiv-method, - exception-message-attribute, - invalid-str-codec, - sys-max-int, - bad-python3-import, - deprecated-string-function, - deprecated-str-translate-call, - deprecated-itertools-function, - deprecated-types-field, - next-method-defined, - dict-items-not-iterating, - dict-keys-not-iterating, - dict-values-not-iterating, - deprecated-operator-function, - deprecated-urllib-function, - xreadlines-attribute, - deprecated-sys-function, - exception-escape, - comprehension-escape, - missing-class-docstring, - logging-fstring-interpolation - -# Enable the message, report, category or checker with the given id(s). You can -# either give multiple identifier separated by comma (,) or put this option -# multiple time (only on the command line, not in the configuration file where -# it should appear only once). See also the "--disable" option for examples. -enable=c-extension-no-member - - -[REPORTS] - -# Python expression which should return a score less than or equal to 10. You -# have access to the variables 'error', 'warning', 'refactor', and 'convention' -# which contain the number of messages in each category, as well as 'statement' -# which is the total number of statements analyzed. This score is used by the -# global evaluation report (RP0004). -evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) - -# Template used to display messages. This is a python new-style format string -# used to format the message information. See doc for all details. -#msg-template= - -# Set the output format. Available formats are text, parseable, colorized, json -# and msvs (visual studio). You can also give a reporter class, e.g. -# mypackage.mymodule.MyReporterClass. -output-format=text - -# Tells whether to display a full report or only the messages. -reports=no - -# Activate the evaluation score. -score=yes - - -[REFACTORING] - -# Maximum number of nested blocks for function / method body -max-nested-blocks=5 - -# Complete name of functions that never returns. When checking for -# inconsistent-return-statements if a never returning function is called then -# it will be considered as an explicit return statement and no message will be -# printed. -never-returning-functions=sys.exit - - -[STRING] - -# This flag controls whether inconsistent-quotes generates a warning when the -# character used as a quote delimiter is used inconsistently within a module. -check-quote-consistency=no - -# This flag controls whether the implicit-str-concat should generate a warning -# on implicit string concatenation in sequences defined over several lines. -check-str-concat-over-line-jumps=no - - -[MISCELLANEOUS] - -# List of note tags to take in consideration, separated by a comma. -notes=FIXME, - XXX, - TODO - -# Regular expression of note tags to take in consideration. -#notes-rgx= - - -[VARIABLES] - -# List of additional names supposed to be defined in builtins. Remember that -# you should avoid defining new builtins when possible. -additional-builtins= - -# Tells whether unused global variables should be treated as a violation. -allow-global-unused-variables=yes - -# List of names allowed to shadow builtins -allowed-redefined-builtins= - -# List of strings which can identify a callback function by name. A callback -# name must start or end with one of those strings. -callbacks=cb_, - _cb - -# A regular expression matching the name of dummy variables (i.e. expected to -# not be used). -dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ - -# Argument names that match this expression will be ignored. Default to name -# with leading underscore. -ignored-argument-names=_.*|^ignored_|^unused_ - -# Tells whether we should check for unused import in __init__ files. -init-import=no - -# List of qualified module names which can have objects that can redefine -# builtins. -redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io - - -[TYPECHECK] - -# List of decorators that produce context managers, such as -# contextlib.contextmanager. Add to this list to register other decorators that -# produce valid context managers. -contextmanager-decorators=contextlib.contextmanager - -# List of members which are set dynamically and missed by pylint inference -# system, and so shouldn't trigger E1101 when accessed. Python regular -# expressions are accepted. -generated-members= - -# Tells whether missing members accessed in mixin class should be ignored. A -# mixin class is detected if its name ends with "mixin" (case insensitive). -ignore-mixin-members=yes - -# Tells whether to warn about missing members when the owner of the attribute -# is inferred to be None. -ignore-none=yes - -# This flag controls whether pylint should warn about no-member and similar -# checks whenever an opaque object is returned when inferring. The inference -# can return multiple potential results while evaluating a Python object, but -# some branches might not be evaluated, which results in partial inference. In -# that case, it might be useful to still emit no-member and other checks for -# the rest of the inferred objects. -ignore-on-opaque-inference=yes - -# List of class names for which member attributes should not be checked (useful -# for classes with dynamically set attributes). This supports the use of -# qualified names. -ignored-classes=optparse.Values,thread._local,_thread._local - -# List of module names for which member attributes should not be checked -# (useful for modules/projects where namespaces are manipulated during runtime -# and thus existing member attributes cannot be deduced by static analysis). It -# supports qualified module names, as well as Unix pattern matching. -ignored-modules= - -# Show a hint with possible names when a member name was not found. The aspect -# of finding the hint is based on edit distance. -missing-member-hint=yes - -# The minimum edit distance a name should have in order to be considered a -# similar match for a missing member name. -missing-member-hint-distance=1 - -# The total number of similar names that should be taken in consideration when -# showing a hint for a missing member. -missing-member-max-choices=1 - -# List of decorators that change the signature of a decorated function. -signature-mutators= - - -[BASIC] - -# Naming style matching correct argument names. -argument-naming-style=snake_case - -# Regular expression matching correct argument names. Overrides argument- -# naming-style. -#argument-rgx= - -# Naming style matching correct attribute names. -attr-naming-style=snake_case - -# Regular expression matching correct attribute names. Overrides attr-naming- -# style. -#attr-rgx= - -# Bad variable names which should always be refused, separated by a comma. -bad-names=foo, - bar, - baz, - toto, - tutu, - tata - -# Bad variable names regexes, separated by a comma. If names match any regex, -# they will always be refused -bad-names-rgxs= - -# Naming style matching correct class attribute names. -class-attribute-naming-style=any - -# Regular expression matching correct class attribute names. Overrides class- -# attribute-naming-style. -#class-attribute-rgx= - -# Naming style matching correct class constant names. -class-const-naming-style=UPPER_CASE - -# Regular expression matching correct class constant names. Overrides class- -# const-naming-style. -#class-const-rgx= - -# Naming style matching correct class names. -class-naming-style=PascalCase - -# Regular expression matching correct class names. Overrides class-naming- -# style. -#class-rgx= - -# Naming style matching correct constant names. -const-naming-style=UPPER_CASE - -# Regular expression matching correct constant names. Overrides const-naming- -# style. -#const-rgx= - -# Minimum line length for functions/classes that require docstrings, shorter -# ones are exempt. -docstring-min-length=-1 - -# Naming style matching correct function names. -function-naming-style=snake_case - -# Regular expression matching correct function names. Overrides function- -# naming-style. -#function-rgx= - -# Good variable names which should always be accepted, separated by a comma. -good-names=i, - j, - k, - ex, - Run, - _ - -# Good variable names regexes, separated by a comma. If names match any regex, -# they will always be accepted -good-names-rgxs= - -# Include a hint for the correct naming format with invalid-name. -include-naming-hint=no - -# Naming style matching correct inline iteration names. -inlinevar-naming-style=any - -# Regular expression matching correct inline iteration names. Overrides -# inlinevar-naming-style. -#inlinevar-rgx= - -# Naming style matching correct method names. -method-naming-style=snake_case - -# Regular expression matching correct method names. Overrides method-naming- -# style. -#method-rgx= - -# Naming style matching correct module names. -module-naming-style=snake_case - -# Regular expression matching correct module names. Overrides module-naming- -# style. -#module-rgx= - -# Colon-delimited sets of names that determine each other's naming style when -# the name regexes allow several styles. -name-group= - -# Regular expression which should only match function or class names that do -# not require a docstring. -no-docstring-rgx=^_ - -# List of decorators that produce properties, such as abc.abstractproperty. Add -# to this list to register other decorators that produce valid properties. -# These decorators are taken in consideration only for invalid-name. -property-classes=abc.abstractproperty - -# Naming style matching correct variable names. -variable-naming-style=snake_case - -# Regular expression matching correct variable names. Overrides variable- -# naming-style. -#variable-rgx= - - -[SIMILARITIES] - -# Ignore comments when computing similarities. -ignore-comments=yes - -# Ignore docstrings when computing similarities. -ignore-docstrings=yes - -# Ignore imports when computing similarities. -ignore-imports=no - -# Minimum lines number of a similarity. -min-similarity-lines=4 - - -[FORMAT] - -# Expected format of line ending, e.g. empty (any line ending), LF or CRLF. -expected-line-ending-format= - -# Regexp for a line that is allowed to be longer than the limit. -ignore-long-lines=^\s*(# )??$ - -# Number of spaces of indent required inside a hanging or continued line. -indent-after-paren=4 - -# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 -# tab). -indent-string=' ' - -# Maximum number of characters on a single line. -max-line-length=140 - -# Maximum number of lines in a module. -max-module-lines=1000 - -# Allow the body of a class to be on the same line as the declaration if body -# contains single statement. -single-line-class-stmt=no - -# Allow the body of an if to be on the same line as the test if there is no -# else. -single-line-if-stmt=no - - -[SPELLING] - -# Limits count of emitted suggestions for spelling mistakes. -max-spelling-suggestions=4 - -# Spelling dictionary name. Available dictionaries: none. To make it work, -# install the 'python-enchant' package. -spelling-dict= - -# List of comma separated words that should not be checked. -spelling-ignore-words= - -# A path to a file that contains the private dictionary; one word per line. -spelling-private-dict-file= - -# Tells whether to store unknown words to the private dictionary (see the -# --spelling-private-dict-file option) instead of raising a message. -spelling-store-unknown-words=no - - -[LOGGING] - -# The type of string formatting that logging methods do. `old` means using % -# formatting, `new` is for `{}` formatting. -logging-format-style=old - -# Logging modules to check that the string format arguments are in logging -# function parameter format. -logging-modules=logging - - -[DESIGN] - -# Maximum number of arguments for function / method. -max-args=5 - -# Maximum number of attributes for a class (see R0902). -max-attributes=7 - -# Maximum number of boolean expressions in an if statement (see R0916). -max-bool-expr=5 - -# Maximum number of branch for function / method body. -max-branches=12 - -# Maximum number of locals for function / method body. -max-locals=15 - -# Maximum number of parents for a class (see R0901). -max-parents=7 - -# Maximum number of public methods for a class (see R0904). -max-public-methods=20 - -# Maximum number of return / yield for function / method body. -max-returns=6 - -# Maximum number of statements in function / method body. -max-statements=50 - -# Minimum number of public methods for a class (see R0903). -min-public-methods=2 - - -[CLASSES] - -# Warn about protected attribute access inside special methods -check-protected-access-in-special-methods=no - -# List of method names used to declare (i.e. assign) instance attributes. -defining-attr-methods=__init__, - __new__, - setUp, - __post_init__ - -# List of member names, which should be excluded from the protected access -# warning. -exclude-protected=_asdict, - _fields, - _replace, - _source, - _make - -# List of valid names for the first argument in a class method. -valid-classmethod-first-arg=cls - -# List of valid names for the first argument in a metaclass class method. -valid-metaclass-classmethod-first-arg=cls - - -[IMPORTS] - -# List of modules that can be imported at any level, not just the top level -# one. -allow-any-import-level= - -# Allow wildcard imports from modules that define __all__. -allow-wildcard-with-all=no - -# Analyse import fallback blocks. This can be used to support both Python 2 and -# 3 compatible code, which means that the block might have code that exists -# only in one or another interpreter, leading to false positives when analysed. -analyse-fallback-blocks=no - -# Deprecated modules which should not be used, separated by a comma. -deprecated-modules=optparse,tkinter.tix - -# Output a graph (.gv or any supported image format) of external dependencies -# to the given file (report RP0402 must not be disabled). -ext-import-graph= - -# Output a graph (.gv or any supported image format) of all (i.e. internal and -# external) dependencies to the given file (report RP0402 must not be -# disabled). -import-graph= - -# Output a graph (.gv or any supported image format) of internal dependencies -# to the given file (report RP0402 must not be disabled). -int-import-graph= - -# Force import order to recognize a module as part of the standard -# compatibility libraries. -known-standard-library= - -# Force import order to recognize a module as part of a third party library. -known-third-party=enchant - -# Couples of modules and preferred modules, separated by a comma. -preferred-modules= - - -[EXCEPTIONS] - -# Exceptions that will emit a warning when being caught. Defaults to -# "BaseException, Exception". -overgeneral-exceptions=BaseException, - Exception diff --git a/CLAUDE.md b/CLAUDE.md index d2aae08..bc22b0f 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -18,7 +18,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co ### Code Quality - `poetry run black .` - Format code with Black (line length: 120) -- `poetry run pylint leverage/` - Run linting +- `poetry run ruff check .` - Run linting (rules in `[tool.ruff]` in `pyproject.toml`) - `poetry run pre-commit install` - Install pre-commit hooks - `poetry run pre-commit run --all-files` - Run pre-commit checks manually diff --git a/README.md b/README.md index c669f7b..869ee37 100644 --- a/README.md +++ b/README.md @@ -171,7 +171,7 @@ poetry shell ## Pre-commit hooks -In order to run black automatically on every commit, you should install `pre-commit` first: +In order to run black and ruff automatically on every commit, you should install `pre-commit` first: https://pre-commit.com/#installation diff --git a/leverage/logger.py b/leverage/logger.py index 7a178cb..c7d22f4 100644 --- a/leverage/logger.py +++ b/leverage/logger.py @@ -15,7 +15,11 @@ "[bold light_yellow3][ %(build_script)s -[/bold light_yellow3]" " %(message)s [bold light_yellow3]][/bold light_yellow3]" ) -_TIME_FORMAT = lambda time: f"[{time:%H:%M:%S}.{time.microsecond//1000:03}]" + + +def _TIME_FORMAT(time): + return f"[{time:%H:%M:%S}.{time.microsecond//1000:03}]" + _leverage_logger = logging.getLogger("leverage") diff --git a/leverage/modules/auth.py b/leverage/modules/auth.py index e057d62..ef9ed72 100644 --- a/leverage/modules/auth.py +++ b/leverage/modules/auth.py @@ -558,4 +558,4 @@ def refresh_layer_credentials_mfa(paths: PathsHandler): "aws_session_token": credentials["SessionToken"], }, ) - logger.info(f"Credentials written successfully.") + logger.info("Credentials written successfully.") diff --git a/leverage/modules/aws.py b/leverage/modules/aws.py index 58fd356..db4412f 100644 --- a/leverage/modules/aws.py +++ b/leverage/modules/aws.py @@ -83,7 +83,7 @@ def configure_sso_profiles(paths: PathsHandler) -> None: # then set a profile for each account access_token = get_sso_access_token(paths.sso_token_file) - logger.info(f"Fetching accounts and roles...") + logger.info("Fetching accounts and roles...") client = boto3.client("sso", region_name=region) account_roles = get_account_roles(client, access_token) for acc_name, values in account_roles.items(): @@ -106,8 +106,8 @@ def aws(context: click.Context, state: Any, args: Tuple[str, ...]) -> None: state.runner = Runner( binary="aws", error_message=( - f"AWS CLI not found on system. " - f"Please install it following the instructions at: https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html" + "AWS CLI not found on system. " + "Please install it following the instructions at: https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html" ), env_vars=state.environment, ) @@ -246,10 +246,10 @@ def login(awscli: Runner, paths: PathsHandler, refresh_all: bool) -> None: paths.sso_cache.mkdir(parents=True, exist_ok=True) - logger.info(f"Logging in...") + logger.info("Logging in...") sso_oidc_client = boto3.client("sso-oidc", region_name=region) - logger.debug(f"Registering client...") + logger.debug("Registering client...") sso_oidc_client_creds = sso_oidc_client.register_client( clientName=f"leverage-{datetime.datetime.now().timestamp()}", clientType="public", @@ -271,7 +271,7 @@ def login(awscli: Runner, paths: PathsHandler, refresh_all: bool) -> None: f"{paths.common_conf.get('sso_start_url')}/#/device?user_code={device_authorization['userCode']}" ) - logger.debug(f"Attempting to create authorization token...") + logger.debug("Attempting to create authorization token...") _wait_interval = device_authorization["interval"] token = None while not token: @@ -309,11 +309,11 @@ def login(awscli: Runner, paths: PathsHandler, refresh_all: bool) -> None: ) logger.debug(f"Token expires at: {token['expiresAt']}") - logger.debug(f"Caching token.") + logger.debug("Caching token.") token_file = paths.sso_cache / "token" token_file.write_text(json.dumps(token)) - logger.info(f"Successfully logged in!.") + logger.info("Successfully logged in!.") if refresh_all: refresh_all_accounts_credentials(paths, force_refresh=False) diff --git a/leverage/modules/credentials.py b/leverage/modules/credentials.py index d6ccc9d..f5e546d 100644 --- a/leverage/modules/credentials.py +++ b/leverage/modules/credentials.py @@ -305,8 +305,8 @@ def credentials(state): state.runner = Runner( binary="aws", error_message=( - f"AWS CLI not found on system. " - f"Please install it following the instructions at: https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html" + "AWS CLI not found on system. " + "Please install it following the instructions at: https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html" ), env_vars=state.environment, ) @@ -345,7 +345,7 @@ def _load_configs_for_credentials(paths: PathsHandler, state: State): # region_primary was added in ref-arch v1 # for v2 it was replaced by region at project level region_primary = "region_primary" - if not "region_primary" in project_config and not "region_primary" in terraform_config: + if "region_primary" not in project_config and "region_primary" not in terraform_config: region_primary = "region" config_values["primary_region"] = ( project_config.get(region_primary) or terraform_config.get(region_primary) or _ask_for_region() diff --git a/leverage/modules/kubectl.py b/leverage/modules/kubectl.py index 75f9903..3cee45e 100644 --- a/leverage/modules/kubectl.py +++ b/leverage/modules/kubectl.py @@ -10,7 +10,6 @@ from leverage import logger from leverage.path import PathsHandler from leverage._utils import ExitError -from leverage.modules.aws import aws from leverage.modules.runner import Runner from leverage.modules.tfrunner import TFRunner from leverage.modules.utils import _handle_subcommand @@ -46,8 +45,8 @@ def kubectl(context, state, args): state.runner = Runner( binary="kubectl", error_message=( - f"Kubectl not found on system. " - f"Please install it following the instructions at: https://kubernetes.io/docs/tasks/tools/#kubectl" + "Kubectl not found on system. " + "Please install it following the instructions at: https://kubernetes.io/docs/tasks/tools/#kubectl" ), env_vars=state.environment, ) @@ -72,7 +71,7 @@ def _configure(environment: dict, ci: ClusterInfo = None, layer_path: Path = Non try: exit_code, _, _ = Runner(binary="aws", env_vars=environment).exec(*cmd) except ExitError as e: - raise ExitError(e.exit_code, f"Could not locate AWS cli binary.") + raise ExitError(e.exit_code, "Could not locate AWS cli binary.") if exit_code: raise ExitError(exit_code, f"Failed to configure kubectl context: {exit_code}") @@ -88,7 +87,7 @@ def _get_eks_kube_config(paths: PathsHandler, environment: dict, layer_path: Pat try: tfrunner = TFRunner(binary=paths.tf_binary, terraform=True, env_vars=environment) except ExitError: - raise ExitError(e.exit_code, f"Could not locate TF binary.") + raise ExitError(e.exit_code, "Could not locate TF binary.") perform_authentication(paths) exit_code, output, error = tfrunner.exec("output", "-no-color", working_dir=layer_path) diff --git a/leverage/modules/project.py b/leverage/modules/project.py index 3f5973b..3470159 100644 --- a/leverage/modules/project.py +++ b/leverage/modules/project.py @@ -16,7 +16,6 @@ from leverage import logger from leverage.path import get_project_root_or_current_dir_path -from leverage.path import NotARepositoryError from leverage.modules.tfrunner import TFRunner from leverage._utils import git, ExitError diff --git a/leverage/modules/tf.py b/leverage/modules/tf.py index d3c217f..1c9ba20 100644 --- a/leverage/modules/tf.py +++ b/leverage/modules/tf.py @@ -385,7 +385,7 @@ def has_a_plan_file(args: Sequence[str]) -> bool: if len(args) > 1: second_last = args[-2] if second_last.startswith("-"): - if not "=" in second_last and second_last not in tf_flags: + if "=" not in second_last and second_last not in tf_flags: return False return True diff --git a/leverage/modules/tfautomv.py b/leverage/modules/tfautomv.py index 7f0bcbe..a05321d 100644 --- a/leverage/modules/tfautomv.py +++ b/leverage/modules/tfautomv.py @@ -20,8 +20,8 @@ def tfautomv(state, args): state.runner = Runner( binary="tfautomv", error_message=( - f"TFAutomv not found on system. " - f"Please install it following the instructions at: https://github.com/busser/tfautomv?tab=readme-ov-file#installation" + "TFAutomv not found on system. " + "Please install it following the instructions at: https://github.com/busser/tfautomv?tab=readme-ov-file#installation" ), env_vars=state.environment, ) diff --git a/leverage/modules/tfrunner.py b/leverage/modules/tfrunner.py index ee4dd7c..d591be0 100644 --- a/leverage/modules/tfrunner.py +++ b/leverage/modules/tfrunner.py @@ -2,7 +2,6 @@ from pathlib import Path from typing import Dict, Optional -from click.exceptions import Exit from leverage._utils import ExitError from leverage.modules.runner import Runner diff --git a/leverage/path.py b/leverage/path.py index 346a152..54e9d9c 100644 --- a/leverage/path.py +++ b/leverage/path.py @@ -51,7 +51,7 @@ def get_root_path(): except CalledProcessError as exc: if "fatal: not a git repository" in exc.stderr: raise NotARepositoryError("Not running in a git repository.") - except FileNotFoundError as exc: + except FileNotFoundError: raise NotARepositoryError("Not running in a git repository.") else: return root.strip() diff --git a/poetry.lock b/poetry.lock index 0389d9d..f367d02 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,26 +1,9 @@ -# This file is automatically @generated by Poetry 1.4.2 and should not be changed by hand. - -[[package]] -name = "astroid" -version = "2.5.6" -description = "An abstract syntax tree for Python with inference support." -category = "dev" -optional = false -python-versions = "~=3.6" -files = [ - {file = "astroid-2.5.6-py3-none-any.whl", hash = "sha256:4db03ab5fc3340cf619dbc25e42c2cc3755154ce6009469766d7143d1fc2ee4e"}, - {file = "astroid-2.5.6.tar.gz", hash = "sha256:8a398dfce302c13f14bab13e2b14fe385d32b73f4e4853b9bdfb64598baa1975"}, -] - -[package.dependencies] -lazy-object-proxy = ">=1.4.0" -wrapt = ">=1.11,<1.13" +# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. [[package]] name = "backports-tarfile" version = "1.2.0" description = "Backport of CPython tarfile module" -category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -36,7 +19,6 @@ testing = ["jaraco.test", "pytest (!=8.0.*)", "pytest (>=6,!=8.1.*)", "pytest-ch name = "black" version = "23.3.0" description = "The uncompromising code formatter." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -86,7 +68,6 @@ uvloop = ["uvloop (>=0.15.2)"] name = "boto3" version = "1.33.2" description = "The AWS SDK for Python" -category = "main" optional = false python-versions = ">= 3.7" files = [ @@ -106,7 +87,6 @@ crt = ["botocore[crt] (>=1.21.0,<2.0a0)"] name = "botocore" version = "1.33.13" description = "Low-level, data-driven core of boto 3." -category = "main" optional = false python-versions = ">= 3.7" files = [ @@ -129,7 +109,6 @@ crt = ["awscrt (==0.19.17)"] name = "certifi" version = "2025.11.12" description = "Python package for providing Mozilla's CA Bundle." -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -141,7 +120,6 @@ files = [ name = "cffi" version = "2.0.0" description = "Foreign Function Interface for Python calling C code." -category = "dev" optional = false python-versions = ">=3.9" files = [ @@ -238,7 +216,6 @@ pycparser = {version = "*", markers = "implementation_name != \"PyPy\""} name = "cfgv" version = "3.4.0" description = "Validate configuration and produce human readable error messages." -category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -250,7 +227,6 @@ files = [ name = "charset-normalizer" version = "3.4.4" description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet." -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -373,7 +349,6 @@ files = [ name = "click" version = "8.0.1" description = "Composable command line interface toolkit" -category = "main" optional = false python-versions = ">=3.6" files = [ @@ -388,7 +363,6 @@ colorama = {version = "*", markers = "platform_system == \"Windows\""} name = "colorama" version = "0.4.6" description = "Cross-platform colored terminal text." -category = "main" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" files = [ @@ -400,7 +374,6 @@ files = [ name = "configupdater" version = "3.2" description = "Parser like ConfigParser but for updating configuration files" -category = "main" optional = false python-versions = ">=3.6" files = [ @@ -415,7 +388,6 @@ testing = ["flake8", "pytest", "pytest-cov", "pytest-randomly", "pytest-xdist", name = "coverage" version = "7.10.7" description = "Code coverage measurement for Python" -category = "dev" optional = false python-versions = ">=3.9" files = [ @@ -535,7 +507,6 @@ toml = ["tomli"] name = "cryptography" version = "43.0.3" description = "cryptography is a package which provides cryptographic recipes and primitives to Python developers." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -585,7 +556,6 @@ test-randomorder = ["pytest-randomly"] name = "distlib" version = "0.4.0" description = "Distribution utilities" -category = "dev" optional = false python-versions = "*" files = [ @@ -597,7 +567,6 @@ files = [ name = "docutils" version = "0.17.1" description = "Docutils -- Python Documentation Utilities" -category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" files = [ @@ -609,7 +578,6 @@ files = [ name = "exceptiongroup" version = "1.3.1" description = "Backport of PEP 654 (exception groups)" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -627,7 +595,6 @@ test = ["pytest (>=6)"] name = "filelock" version = "3.19.1" description = "A platform independent file lock." -category = "dev" optional = false python-versions = ">=3.9" files = [ @@ -639,7 +606,6 @@ files = [ name = "id" version = "1.5.0" description = "A tool for generating OIDC identities" -category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -659,7 +625,6 @@ test = ["coverage[toml]", "pretend", "pytest", "pytest-cov"] name = "identify" version = "2.6.15" description = "File identification library for Python" -category = "dev" optional = false python-versions = ">=3.9" files = [ @@ -674,7 +639,6 @@ license = ["ukkonen"] name = "idna" version = "3.11" description = "Internationalized Domain Names in Applications (IDNA)" -category = "main" optional = false python-versions = ">=3.8" files = [ @@ -689,7 +653,6 @@ all = ["flake8 (>=7.1.1)", "mypy (>=1.11.2)", "pytest (>=8.3.2)", "ruff (>=0.6.2 name = "importlib-metadata" version = "8.7.0" description = "Read metadata from Python packages" -category = "dev" optional = false python-versions = ">=3.9" files = [ @@ -713,7 +676,6 @@ type = ["pytest-mypy"] name = "iniconfig" version = "2.1.0" description = "brain-dead simple config-ini parsing" -category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -721,26 +683,10 @@ files = [ {file = "iniconfig-2.1.0.tar.gz", hash = "sha256:3abbd2e30b36733fee78f9c7f7308f2d0050e88f0087fd25c2645f63c773e1c7"}, ] -[[package]] -name = "isort" -version = "5.13.2" -description = "A Python utility / library to sort Python imports." -category = "dev" -optional = false -python-versions = ">=3.8.0" -files = [ - {file = "isort-5.13.2-py3-none-any.whl", hash = "sha256:8ca5e72a8d85860d5a3fa69b8745237f2939afe12dbf656afbcb47fe72d947a6"}, - {file = "isort-5.13.2.tar.gz", hash = "sha256:48fdfcb9face5d58a4f6dde2e72a1fb8dcaf8ab26f95ab49fab84c2ddefb0109"}, -] - -[package.extras] -colors = ["colorama (>=0.4.6)"] - [[package]] name = "jaraco-classes" version = "3.4.0" description = "Utility functions for Python class constructs" -category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -759,7 +705,6 @@ testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-ena name = "jaraco-context" version = "6.0.1" description = "Useful decorators and context managers" -category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -778,7 +723,6 @@ test = ["portend", "pytest (>=6,!=8.1.*)", "pytest-checkdocs (>=2.4)", "pytest-c name = "jaraco-functools" version = "4.3.0" description = "Functools like those found in stdlib" -category = "dev" optional = false python-versions = ">=3.9" files = [ @@ -801,7 +745,6 @@ type = ["pytest-mypy"] name = "jeepney" version = "0.9.0" description = "Low-level, pure Python DBus protocol wrapper." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -817,7 +760,6 @@ trio = ["trio"] name = "jinja2" version = "3.0.1" description = "A very fast and expressive template engine." -category = "main" optional = false python-versions = ">=3.6" files = [ @@ -835,7 +777,6 @@ i18n = ["Babel (>=2.7)"] name = "jmespath" version = "1.0.1" description = "JSON Matching Expressions" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -847,7 +788,6 @@ files = [ name = "keyring" version = "25.7.0" description = "Store and access your passwords safely." -category = "dev" optional = false python-versions = ">=3.9" files = [ @@ -877,7 +817,6 @@ type = ["pygobject-stubs", "pytest-mypy (>=1.0.1)", "shtab", "types-pywin32"] name = "lark" version = "1.3.1" description = "a modern parsing library" -category = "main" optional = false python-versions = ">=3.8" files = [ @@ -891,65 +830,10 @@ interegular = ["interegular (>=0.3.1,<0.4.0)"] nearley = ["js2py"] regex = ["regex"] -[[package]] -name = "lazy-object-proxy" -version = "1.12.0" -description = "A fast and thorough lazy object proxy." -category = "dev" -optional = false -python-versions = ">=3.9" -files = [ - {file = "lazy_object_proxy-1.12.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:61d5e3310a4aa5792c2b599a7a78ccf8687292c8eb09cf187cca8f09cf6a7519"}, - {file = "lazy_object_proxy-1.12.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c1ca33565f698ac1aece152a10f432415d1a2aa9a42dfe23e5ba2bc255ab91f6"}, - {file = "lazy_object_proxy-1.12.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d01c7819a410f7c255b20799b65d36b414379a30c6f1684c7bd7eb6777338c1b"}, - {file = "lazy_object_proxy-1.12.0-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:029d2b355076710505c9545aef5ab3f750d89779310e26ddf2b7b23f6ea03cd8"}, - {file = "lazy_object_proxy-1.12.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:cc6e3614eca88b1c8a625fc0a47d0d745e7c3255b21dac0e30b3037c5e3deeb8"}, - {file = "lazy_object_proxy-1.12.0-cp310-cp310-win_amd64.whl", hash = "sha256:be5fe974e39ceb0d6c9db0663c0464669cf866b2851c73971409b9566e880eab"}, - {file = "lazy_object_proxy-1.12.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:1cf69cd1a6c7fe2dbcc3edaa017cf010f4192e53796538cc7d5e1fedbfa4bcff"}, - {file = "lazy_object_proxy-1.12.0-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:efff4375a8c52f55a145dc8487a2108c2140f0bec4151ab4e1843e52eb9987ad"}, - {file = "lazy_object_proxy-1.12.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:1192e8c2f1031a6ff453ee40213afa01ba765b3dc861302cd91dbdb2e2660b00"}, - {file = "lazy_object_proxy-1.12.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:3605b632e82a1cbc32a1e5034278a64db555b3496e0795723ee697006b980508"}, - {file = "lazy_object_proxy-1.12.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:a61095f5d9d1a743e1e20ec6d6db6c2ca511961777257ebd9b288951b23b44fa"}, - {file = "lazy_object_proxy-1.12.0-cp311-cp311-win_amd64.whl", hash = "sha256:997b1d6e10ecc6fb6fe0f2c959791ae59599f41da61d652f6c903d1ee58b7370"}, - {file = "lazy_object_proxy-1.12.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:8ee0d6027b760a11cc18281e702c0309dd92da458a74b4c15025d7fc490deede"}, - {file = "lazy_object_proxy-1.12.0-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:4ab2c584e3cc8be0dfca422e05ad30a9abe3555ce63e9ab7a559f62f8dbc6ff9"}, - {file = "lazy_object_proxy-1.12.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:14e348185adbd03ec17d051e169ec45686dcd840a3779c9d4c10aabe2ca6e1c0"}, - {file = "lazy_object_proxy-1.12.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:c4fcbe74fb85df8ba7825fa05eddca764138da752904b378f0ae5ab33a36c308"}, - {file = "lazy_object_proxy-1.12.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:563d2ec8e4d4b68ee7848c5ab4d6057a6d703cb7963b342968bb8758dda33a23"}, - {file = "lazy_object_proxy-1.12.0-cp312-cp312-win_amd64.whl", hash = "sha256:53c7fd99eb156bbb82cbc5d5188891d8fdd805ba6c1e3b92b90092da2a837073"}, - {file = "lazy_object_proxy-1.12.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:86fd61cb2ba249b9f436d789d1356deae69ad3231dc3c0f17293ac535162672e"}, - {file = "lazy_object_proxy-1.12.0-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:81d1852fb30fab81696f93db1b1e55a5d1ff7940838191062f5f56987d5fcc3e"}, - {file = "lazy_object_proxy-1.12.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:be9045646d83f6c2664c1330904b245ae2371b5c57a3195e4028aedc9f999655"}, - {file = "lazy_object_proxy-1.12.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:67f07ab742f1adfb3966c40f630baaa7902be4222a17941f3d85fd1dae5565ff"}, - {file = "lazy_object_proxy-1.12.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:75ba769017b944fcacbf6a80c18b2761a1795b03f8899acdad1f1c39db4409be"}, - {file = "lazy_object_proxy-1.12.0-cp313-cp313-win_amd64.whl", hash = "sha256:7b22c2bbfb155706b928ac4d74c1a63ac8552a55ba7fff4445155523ea4067e1"}, - {file = "lazy_object_proxy-1.12.0-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:4a79b909aa16bde8ae606f06e6bbc9d3219d2e57fb3e0076e17879072b742c65"}, - {file = "lazy_object_proxy-1.12.0-cp313-cp313t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:338ab2f132276203e404951205fe80c3fd59429b3a724e7b662b2eb539bb1be9"}, - {file = "lazy_object_proxy-1.12.0-cp313-cp313t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:8c40b3c9faee2e32bfce0df4ae63f4e73529766893258eca78548bac801c8f66"}, - {file = "lazy_object_proxy-1.12.0-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:717484c309df78cedf48396e420fa57fc8a2b1f06ea889df7248fdd156e58847"}, - {file = "lazy_object_proxy-1.12.0-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:a6b7ea5ea1ffe15059eb44bcbcb258f97bcb40e139b88152c40d07b1a1dfc9ac"}, - {file = "lazy_object_proxy-1.12.0-cp313-cp313t-win_amd64.whl", hash = "sha256:08c465fb5cd23527512f9bd7b4c7ba6cec33e28aad36fbbe46bf7b858f9f3f7f"}, - {file = "lazy_object_proxy-1.12.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:c9defba70ab943f1df98a656247966d7729da2fe9c2d5d85346464bf320820a3"}, - {file = "lazy_object_proxy-1.12.0-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:6763941dbf97eea6b90f5b06eb4da9418cc088fce0e3883f5816090f9afcde4a"}, - {file = "lazy_object_proxy-1.12.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:fdc70d81235fc586b9e3d1aeef7d1553259b62ecaae9db2167a5d2550dcc391a"}, - {file = "lazy_object_proxy-1.12.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:0a83c6f7a6b2bfc11ef3ed67f8cbe99f8ff500b05655d8e7df9aab993a6abc95"}, - {file = "lazy_object_proxy-1.12.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:256262384ebd2a77b023ad02fbcc9326282bcfd16484d5531154b02bc304f4c5"}, - {file = "lazy_object_proxy-1.12.0-cp314-cp314-win_amd64.whl", hash = "sha256:7601ec171c7e8584f8ff3f4e440aa2eebf93e854f04639263875b8c2971f819f"}, - {file = "lazy_object_proxy-1.12.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:ae575ad9b674d0029fc077c5231b3bc6b433a3d1a62a8c363df96974b5534728"}, - {file = "lazy_object_proxy-1.12.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:31020c84005d3daa4cc0fa5a310af2066efe6b0d82aeebf9ab199292652ff036"}, - {file = "lazy_object_proxy-1.12.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:800f32b00a47c27446a2b767df7538e6c66a3488632c402b4fb2224f9794f3c0"}, - {file = "lazy_object_proxy-1.12.0-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:15400b18893f345857b9e18b9bd87bd06aba84af6ed086187add70aeaa3f93f1"}, - {file = "lazy_object_proxy-1.12.0-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:3d3964fbd326578bcdfffd017ef101b6fb0484f34e731fe060ba9b8816498c36"}, - {file = "lazy_object_proxy-1.12.0-cp39-cp39-win_amd64.whl", hash = "sha256:424a8ab6695400845c39f13c685050eab69fa0bbac5790b201cd27375e5e41d7"}, - {file = "lazy_object_proxy-1.12.0-pp39.pp310.pp311.graalpy311-none-any.whl", hash = "sha256:c3b2e0af1f7f77c4263759c4824316ce458fabe0fceadcd24ef8ca08b2d1e402"}, - {file = "lazy_object_proxy-1.12.0.tar.gz", hash = "sha256:1f5a462d92fd0cfb82f1fab28b51bfb209fabbe6aabf7f0d51472c0c124c0c61"}, -] - [[package]] name = "markdown-it-py" version = "3.0.0" description = "Python port of markdown-it. Markdown parsing, done right!" -category = "main" optional = false python-versions = ">=3.8" files = [ @@ -974,7 +858,6 @@ testing = ["coverage", "pytest", "pytest-cov", "pytest-regressions"] name = "markupsafe" version = "3.0.3" description = "Safely add untrusted strings to HTML/XML markup." -category = "main" optional = false python-versions = ">=3.9" files = [ @@ -1069,23 +952,10 @@ files = [ {file = "markupsafe-3.0.3.tar.gz", hash = "sha256:722695808f4b6457b320fdc131280796bdceb04ab50fe1795cd540799ebe1698"}, ] -[[package]] -name = "mccabe" -version = "0.6.1" -description = "McCabe checker, plugin for flake8" -category = "dev" -optional = false -python-versions = "*" -files = [ - {file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"}, - {file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"}, -] - [[package]] name = "mdurl" version = "0.1.2" description = "Markdown URL utilities" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -1097,7 +967,6 @@ files = [ name = "more-itertools" version = "10.8.0" description = "More routines for operating on iterables, beyond itertools" -category = "dev" optional = false python-versions = ">=3.9" files = [ @@ -1109,7 +978,6 @@ files = [ name = "mypy-extensions" version = "1.1.0" description = "Type system extensions for programs checked with the mypy type checker." -category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -1121,7 +989,6 @@ files = [ name = "nh3" version = "0.3.2" description = "Python binding to Ammonia HTML sanitizer Rust crate" -category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -1157,7 +1024,6 @@ files = [ name = "nodeenv" version = "1.9.1" description = "Node.js virtual environment builder" -category = "dev" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" files = [ @@ -1169,7 +1035,6 @@ files = [ name = "packaging" version = "25.0" description = "Core utilities for Python packages" -category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -1181,7 +1046,6 @@ files = [ name = "pathspec" version = "0.12.1" description = "Utility library for gitignore style pattern matching of file paths." -category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -1193,7 +1057,6 @@ files = [ name = "platformdirs" version = "4.4.0" description = "A small Python package for determining appropriate platform-specific dirs, e.g. a `user data dir`." -category = "dev" optional = false python-versions = ">=3.9" files = [ @@ -1210,7 +1073,6 @@ type = ["mypy (>=1.14.1)"] name = "pluggy" version = "1.6.0" description = "plugin and hook calling mechanisms for python" -category = "dev" optional = false python-versions = ">=3.9" files = [ @@ -1226,7 +1088,6 @@ testing = ["coverage", "pytest", "pytest-benchmark"] name = "pre-commit" version = "3.5.0" description = "A framework for managing and maintaining multi-language pre-commit hooks." -category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -1245,7 +1106,6 @@ virtualenv = ">=20.10.0" name = "prompt-toolkit" version = "3.0.51" description = "Library for building powerful interactive command lines in Python" -category = "main" optional = false python-versions = ">=3.8" files = [ @@ -1260,7 +1120,6 @@ wcwidth = "*" name = "pycparser" version = "2.23" description = "C parser in Python" -category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -1272,7 +1131,6 @@ files = [ name = "pygments" version = "2.19.2" description = "Pygments is a syntax highlighting package written in Python." -category = "main" optional = false python-versions = ">=3.8" files = [ @@ -1283,30 +1141,10 @@ files = [ [package.extras] windows-terminal = ["colorama (>=0.4.6)"] -[[package]] -name = "pylint" -version = "2.8.3" -description = "python code static checker" -category = "dev" -optional = false -python-versions = "~=3.6" -files = [ - {file = "pylint-2.8.3-py3-none-any.whl", hash = "sha256:792b38ff30903884e4a9eab814ee3523731abd3c463f3ba48d7b627e87013484"}, - {file = "pylint-2.8.3.tar.gz", hash = "sha256:0a049c5d47b629d9070c3932d13bff482b12119b6a241a93bc460b0be16953c8"}, -] - -[package.dependencies] -astroid = "2.5.6" -colorama = {version = "*", markers = "sys_platform == \"win32\""} -isort = ">=4.2.5,<6" -mccabe = ">=0.6,<0.7" -toml = ">=0.7.1" - [[package]] name = "pytest" version = "8.3.3" description = "pytest: simple powerful testing with Python" -category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -1329,7 +1167,6 @@ dev = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "pygments name = "pytest-cov" version = "6.0.0" description = "Pytest plugin for measuring coverage." -category = "dev" optional = false python-versions = ">=3.9" files = [ @@ -1348,7 +1185,6 @@ testing = ["fields", "hunter", "process-tests", "pytest-xdist", "virtualenv"] name = "pytest-mock" version = "3.15.1" description = "Thin-wrapper around the mock package for easier use with pytest" -category = "dev" optional = false python-versions = ">=3.9" files = [ @@ -1366,7 +1202,6 @@ dev = ["pre-commit", "pytest-asyncio", "tox"] name = "python-dateutil" version = "2.9.0.post0" description = "Extensions to the standard Python datetime module" -category = "main" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" files = [ @@ -1381,7 +1216,6 @@ six = ">=1.5" name = "python-hcl2" version = "7.3.1" description = "A parser for HCL2" -category = "main" optional = false python-versions = ">=3.7.0" files = [ @@ -1397,7 +1231,6 @@ regex = ">=2024.4.16" name = "pywin32-ctypes" version = "0.2.3" description = "A (partial) reimplementation of pywin32 using ctypes/cffi" -category = "dev" optional = false python-versions = ">=3.6" files = [ @@ -1409,7 +1242,6 @@ files = [ name = "pyyaml" version = "6.0.3" description = "YAML parser and emitter for Python" -category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -1492,7 +1324,6 @@ files = [ name = "questionary" version = "1.10.0" description = "Python library to build pretty command line user prompts ⭐️" -category = "main" optional = false python-versions = ">=3.6,<4.0" files = [ @@ -1510,7 +1341,6 @@ docs = ["Sphinx (>=3.3,<4.0)", "sphinx-autobuild (>=2020.9.1,<2021.0.0)", "sphin name = "readme-renderer" version = "43.0" description = "readme_renderer is a library for rendering readme descriptions for Warehouse" -category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -1530,7 +1360,6 @@ md = ["cmarkgfm (>=0.8.0)"] name = "regex" version = "2025.11.3" description = "Alternative regular expression module, to replace re." -category = "main" optional = false python-versions = ">=3.9" files = [ @@ -1655,7 +1484,6 @@ files = [ name = "requests" version = "2.31.0" description = "Python HTTP for Humans." -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -1677,7 +1505,6 @@ use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] name = "requests-toolbelt" version = "1.0.0" description = "A utility belt for advanced users of python-requests" -category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" files = [ @@ -1692,7 +1519,6 @@ requests = ">=2.0.1,<3.0.0" name = "rfc3986" version = "2.0.0" description = "Validating URI References per RFC 3986" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -1707,7 +1533,6 @@ idna2008 = ["idna"] name = "rich" version = "14.1.0" description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal" -category = "main" optional = false python-versions = ">=3.8.0" files = [ @@ -1726,7 +1551,6 @@ jupyter = ["ipywidgets (>=7.5.1,<9)"] name = "ruamel-yaml" version = "0.17.10" description = "ruamel.yaml is a YAML parser/emitter that supports roundtrip preservation of comments, seq/map flow style, and map key order" -category = "main" optional = false python-versions = ">=3" files = [ @@ -1745,7 +1569,6 @@ jinja2 = ["ruamel.yaml.jinja2 (>=0.2)"] name = "ruamel-yaml-clib" version = "0.2.15" description = "C version of reader, parser and emitter for ruamel.yaml derived from libyaml" -category = "main" optional = false python-versions = ">=3.9" files = [ @@ -1812,11 +1635,37 @@ files = [ {file = "ruamel_yaml_clib-0.2.15.tar.gz", hash = "sha256:46e4cc8c43ef6a94885f72512094e482114a8a706d3c555a34ed4b0d20200600"}, ] +[[package]] +name = "ruff" +version = "0.17.5" +description = "An extremely fast Python linter and code formatter, written in Rust." +optional = false +python-versions = ">=3.7" +files = [ + {file = "ruff-0.17.5-py3-none-linux_armv6l.whl", hash = "sha256:d511dd302982e46a285528942fa6557d57730edc4bdb9def95e86a2603d77396"}, + {file = "ruff-0.17.5-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:b72fbc232e328bdbb9cdddf4f1aedcd61bd1aa64d75fc012114b4add0bd7f26b"}, + {file = "ruff-0.17.5-py3-none-macosx_11_0_arm64.whl", hash = "sha256:6f0db748508f04a04e3fbebcc636a5c8b3bd76274f8ed28f497c44d75c2ea2d7"}, + {file = "ruff-0.17.5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6f6a7b138edf9cc402ca736a59d9525e6d766e5395760b72e7e146e6251ac963"}, + {file = "ruff-0.17.5-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:e52622ecf3a0df9d03e796fe3eed4aa085adda65520db7e0619cbd2192a97342"}, + {file = "ruff-0.17.5-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:54c0f67d1be11b55d12c184a819fc229f5eee3ef45c16c4fcad41258e83b4882"}, + {file = "ruff-0.17.5-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:dd0dfe7c6fe5a447fce467c58e69893be1d9a7e4378f5b9906432da33d94a97f"}, + {file = "ruff-0.17.5-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:ec4ecf40fb4d6e1265b009dbe551727920926fc0f769070c452d6d84b422a74d"}, + {file = "ruff-0.17.5-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:40ca8afaac309b41a5b2e09e4e7beb1f824826b93c25697c4d74f573324fba4e"}, + {file = "ruff-0.17.5-py3-none-manylinux_2_31_riscv64.whl", hash = "sha256:8e85601bd6d9b6c3e3b95c0e0dccdbac1d23c6bcef006d187fbcddaf8225a5df"}, + {file = "ruff-0.17.5-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:f93d2b7d449ed9545304f6923699ca20d13c675b69f258481709a08ae61076db"}, + {file = "ruff-0.17.5-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:0e5c125c5b31dc8efc948d41357496a4c4a312977565ccba740030efdff83580"}, + {file = "ruff-0.17.5-py3-none-musllinux_1_2_i686.whl", hash = "sha256:50dfc3c6b3ebd0a932f11dfd579bd42234b0b7137e68940eb6abdbfdb9d69697"}, + {file = "ruff-0.17.5-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:86bd1f3b83c25f9b8055c6e796f0685b39d3127ce947322098c3108cf82fd586"}, + {file = "ruff-0.17.5-py3-none-win32.whl", hash = "sha256:e1546609b2ad73f1d6c5c076881b788672b7b3cc3283981182cbdbb6524ed88a"}, + {file = "ruff-0.17.5-py3-none-win_amd64.whl", hash = "sha256:aa415d57c244299279901d776607fee3df7831c2a7435433fbfacde8632c6550"}, + {file = "ruff-0.17.5-py3-none-win_arm64.whl", hash = "sha256:64a6fd668a336df959c522991de33e9e3c8be463afc0c9ac8f029f9d19ef756e"}, + {file = "ruff-0.17.5.tar.gz", hash = "sha256:625e57d80cd43352d12ea81690f3eac46cddc8c0f35026d137fb0f157f94592e"}, +] + [[package]] name = "s3transfer" version = "0.8.2" description = "An Amazon S3 Transfer Manager" -category = "main" optional = false python-versions = ">= 3.7" files = [ @@ -1834,7 +1683,6 @@ crt = ["botocore[crt] (>=1.33.2,<2.0a.0)"] name = "secretstorage" version = "3.3.3" description = "Python bindings to FreeDesktop.org Secret Service API" -category = "dev" optional = false python-versions = ">=3.6" files = [ @@ -1850,7 +1698,6 @@ jeepney = ">=0.6" name = "simple-term-menu" version = "1.6.4" description = "A Python package which creates simple interactive menus on the command line." -category = "main" optional = false python-versions = "~=3.5" files = [ @@ -1862,7 +1709,6 @@ files = [ name = "six" version = "1.17.0" description = "Python 2 and 3 compatibility utilities" -category = "main" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" files = [ @@ -1870,23 +1716,10 @@ files = [ {file = "six-1.17.0.tar.gz", hash = "sha256:ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81"}, ] -[[package]] -name = "toml" -version = "0.10.2" -description = "Python Library for Tom's Obvious, Minimal Language" -category = "dev" -optional = false -python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" -files = [ - {file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"}, - {file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"}, -] - [[package]] name = "tomli" version = "2.3.0" description = "A lil' TOML parser" -category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -1938,7 +1771,6 @@ files = [ name = "twine" version = "6.1.0" description = "Collection of utilities for publishing packages on PyPI" -category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -1965,7 +1797,6 @@ keyring = ["keyring (>=15.1)"] name = "typing-extensions" version = "4.15.0" description = "Backported and Experimental Type Hints for Python 3.9+" -category = "dev" optional = false python-versions = ">=3.9" files = [ @@ -1977,7 +1808,6 @@ files = [ name = "urllib3" version = "1.26.20" description = "HTTP library with thread-safe connection pooling, file post, and more." -category = "main" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,>=2.7" files = [ @@ -1994,7 +1824,6 @@ socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"] name = "urllib3" version = "2.0.7" description = "HTTP library with thread-safe connection pooling, file post, and more." -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -2012,7 +1841,6 @@ zstd = ["zstandard (>=0.18.0)"] name = "virtualenv" version = "20.35.4" description = "Virtual Python Environment builder" -category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -2034,7 +1862,6 @@ test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess name = "wcwidth" version = "0.2.14" description = "Measures the displayed width of unicode strings in a terminal" -category = "main" optional = false python-versions = ">=3.6" files = [ @@ -2042,22 +1869,10 @@ files = [ {file = "wcwidth-0.2.14.tar.gz", hash = "sha256:4d478375d31bc5395a3c55c40ccdf3354688364cd61c4f6adacaa9215d0b3605"}, ] -[[package]] -name = "wrapt" -version = "1.12.1" -description = "Module for decorators, wrappers and monkey patching." -category = "dev" -optional = false -python-versions = "*" -files = [ - {file = "wrapt-1.12.1.tar.gz", hash = "sha256:b62ffa81fb85f4332a4f609cab4ac40709470da05643a082ec1eb88e6d9b97d7"}, -] - [[package]] name = "yaenv" version = "1.5.3.post1" description = "Yet another dotenv parser for Python." -category = "main" optional = false python-versions = ">=3.9,<4.0" files = [ @@ -2069,7 +1884,6 @@ files = [ name = "zipp" version = "3.23.0" description = "Backport of pathlib-compatible object wrapper for zip files" -category = "dev" optional = false python-versions = ">=3.9" files = [ @@ -2088,4 +1902,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.0" python-versions = "~3.9 || ~3.10 || ~3.11 || ~3.12 || ~3.13" -content-hash = "ce4d9bb8a0938a79412b2184795be64fb896119dec65814486a44fc34f5480f6" +content-hash = "07f2edd42b7bbe1b8c52ee9ea59aba60cb3f755356b8916a2a880cb6e4f55016" diff --git a/pyproject.toml b/pyproject.toml index 795287d..0e46236 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,11 +43,11 @@ simple-term-menu = "1.6.4" python-dateutil = "^2.9.0.post0" [tool.poetry.group.dev.dependencies] -pylint = "2.8.3" pytest = "8.3.3" pytest-cov = "6.0.0" twine = "6.1.0" black = "23.3.0" +ruff = "0.17.5" pre-commit = "3.5.0" pytest-mock = "^3.15.1" @@ -65,3 +65,19 @@ extend-exclude = """ simple_build_bad_syntax.py """ +[tool.ruff] +line-length = 120 +target-version = "py39" +# Deliberately broken: tests/test_tasks.py checks how a build script with a syntax error is reported +extend-exclude = ["tests/build_scripts/simple_build_bad_syntax.py"] + +[tool.ruff.lint] +# pyflakes (F) and the pycodestyle errors (E4, E7, E9): mistakes, not style. black owns the formatting. +select = ["E4", "E7", "E9", "F"] + +[tool.ruff.lint.per-file-ignores] +# The package's public names, imported to be re-exported +"leverage/__init__.py" = ["F401"] +"leverage/modules/__init__.py" = ["F401"] +# TODO: drop once #333 is merged; fixing these f-strings now would conflict with it +"leverage/_backend_config.py" = ["F541"] diff --git a/tests/conftest.py b/tests/conftest.py index db448fb..3fd46aa 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -186,7 +186,7 @@ def leverage_runner(monkeypatch): working_directory: Optional working directory (defaults to account/us-east-1/security-base) """ from contextlib import contextmanager - from leverage.modules import tf, auth + from leverage.modules import auth from leverage.modules.tfrunner import TFRunner def skip_binary_validation(tf_runner): diff --git a/tests/test_conf.py b/tests/test_conf.py index 2d3b85c..0270eb1 100644 --- a/tests/test_conf.py +++ b/tests/test_conf.py @@ -1,6 +1,5 @@ import pytest -from leverage import leverage from leverage.conf import load ROOT_ENV_FILE = """ diff --git a/tests/test_modules/test_kubectl.py b/tests/test_modules/test_kubectl.py index 57c9935..3ec926f 100644 --- a/tests/test_modules/test_kubectl.py +++ b/tests/test_modules/test_kubectl.py @@ -1,7 +1,7 @@ from importlib import import_module from pathlib import Path, PosixPath from unittest import mock -from unittest.mock import Mock, patch +from unittest.mock import patch from click.testing import CliRunner @@ -55,4 +55,5 @@ def test_discover(leverage_project): with patch.object(kubectl_module, "_configure") as mkd_configure: cli_runner.invoke(leverage, ["kubectl", "discover"]) + mkd_scan_clusters.assert_called_once() assert isinstance(mkd_configure.call_args_list[0][0][1], ClusterInfo) diff --git a/tests/test_modules/test_run.py b/tests/test_modules/test_run.py index c26a0d5..5b1bd6d 100644 --- a/tests/test_modules/test_run.py +++ b/tests/test_modules/test_run.py @@ -1,11 +1,8 @@ -import sys import pytest from click.exceptions import Exit from leverage.tasks import _load_build_script -from leverage.logger import _leverage_logger -from leverage.logger import _configure_logger from leverage.modules.run import _prepare_tasks_to_run from leverage.modules.run import TaskNotFoundError from leverage.modules.run import MalformedTaskArgumentError diff --git a/tests/test_modules/test_runner.py b/tests/test_modules/test_runner.py index 8246712..654deb3 100644 --- a/tests/test_modules/test_runner.py +++ b/tests/test_modules/test_runner.py @@ -187,7 +187,7 @@ def test_run_logs_debug_information(mock_runner, tmp_path, mocker): mock_runner.run("arg1", env_vars=env_vars, working_dir=tmp_path) expected_calls = [ - mocker.call(f"[bold cyan]Running command:[/bold cyan] /usr/bin/test_binary arg1"), + mocker.call("[bold cyan]Running command:[/bold cyan] /usr/bin/test_binary arg1"), mocker.call(f"Working directory: {tmp_path}"), mocker.call(f"Additional environment variables: {merged_env_vars}"), ]