Skip to content

Commit

Permalink
Release 3.6.0 (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
radeklat authored Dec 15, 2022
1 parent 178f178 commit a2b8fab
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 58 deletions.
18 changes: 12 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,21 @@ Types of changes are:

## [Unreleased]

## [3.5.0] - 2022-12-14
## [3.6.0] - 2022-12-14

### Features

- Commands using `utils.execute_commands_group` can be decorated with `decorators.pass_args`. Unlike regular passed arguments, this is expected to be a mapping from command name to passed arguments, allowing passing these arguments only to specific commands in the group. Example:
- Commands executed via `utils.execute_commands_group` will receive passed arguments as `passed_args` from config, if they use the `delfino.decorators.pass_args` decorator. Example:
```toml
[tool.delfino.plugins.delfino-core.verify-all.pass_args]
test-all = "-m 'not slow'"
[tool.delfino.plugins.delfino-core.lint-pylint]
pass_args = "--fail-under 0.9"
```
will pass `-m 'not slow'` to `pytest` executed by `test-all`, which is in `verify-all` group.
will pass `--fail-under 0.9` to `pylint` executed by `lint-pylint`, which is in `lint` group, which itself is in `verify-all` group.

## [3.5.0] - 2022-12-14

### Features

- `utils.execute_commands_group` logs a debug message when a command is not executed because it is disabled.

## [3.4.1] - 2022-12-13
Expand Down Expand Up @@ -156,7 +161,8 @@ Types of changes are:

- Initial source code

[Unreleased]: https://github.com/radeklat/delfino-core/compare/3.5.0...HEAD
[Unreleased]: https://github.com/radeklat/delfino-core/compare/3.6.0...HEAD
[3.6.0]: https://github.com/radeklat/delfino-core/compare/3.5.0...3.6.0
[3.5.0]: https://github.com/radeklat/delfino-core/compare/3.4.1...3.5.0
[3.4.1]: https://github.com/radeklat/delfino-core/compare/3.4.0...3.4.1
[3.4.0]: https://github.com/radeklat/delfino-core/compare/3.3.0...3.4.0
Expand Down
57 changes: 24 additions & 33 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name="delfino-core"
version="3.5.0"
version="3.6.0"
authors = ["Radek Lát <[email protected]>"]
description="Delfino core plugin"
license = "MIT License"
Expand All @@ -25,7 +25,7 @@ classifiers = [

[tool.poetry.dependencies]
python = "^3.7.2"
delfino = ">=0.24.0"
delfino = ">=0.27.0"

black = {version = "*", optional = true}
isort = {version = "*", optional = true}
Expand Down Expand Up @@ -148,3 +148,6 @@ add-ignore = [
"D401", # "First line should be in imperative mood"
"D413", # "Missing blank line after last section"
]

[tool.delfino.plugins.local_commands_directory.test-all]
pass_args = "--dfhfadshf"
3 changes: 1 addition & 2 deletions src/delfino_core/commands/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,11 @@ def get_pylintrc_folder(path: Path) -> Path:
@click.command(help="Runs all linting commands. Configured by the ``lint_commands`` setting.")
@files_folders_option
@pass_plugin_app_context
@pass_args
@click.pass_context
def lint(
click_context: click.Context,
app_context: AppContext[CorePluginConfig],
**kwargs,
):
del kwargs # handled by execute_commands_group or passed to downstream commands
del kwargs # passed to downstream commands
execute_commands_group("lint", click_context, app_context.plugin_config)
9 changes: 2 additions & 7 deletions src/delfino_core/commands/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,8 @@ def test(app_context: AppContext[CorePluginConfig], passed_args: Tuple[str, ...]
@pass_plugin_app_context
@pass_args
@click.pass_context
def test_all(
click_context: click.Context,
app_context: AppContext[CorePluginConfig],
passed_args: Tuple[str, ...],
files_folders: Tuple[str, ...],
):
del app_context, passed_args, files_folders # passed to `test`
def test_all(click_context: click.Context, **kwargs):
del kwargs # passed to `test`
click_context.forward(test)
click_context.forward(coverage_report)

Expand Down
5 changes: 1 addition & 4 deletions src/delfino_core/commands/verify_all.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import click
from delfino.decorators import pass_args
from delfino.models import AppContext

from delfino_core.commands.format import run_format
Expand All @@ -14,8 +13,6 @@

@click.command(help="Runs all verification commands. Configured by the ``verify_commands`` setting.")
@pass_plugin_app_context
@pass_args
@click.pass_context
def verify_all(click_context: click.Context, app_context: AppContext[CorePluginConfig], **kwargs):
del kwargs # handled by execute_commands_group
def verify_all(click_context: click.Context, app_context: AppContext[CorePluginConfig]):
execute_commands_group("verify", click_context, app_context.plugin_config)
9 changes: 5 additions & 4 deletions src/delfino_core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import click
from delfino.click_utils.command import get_root_command
from delfino.decorators.pass_args import set_passed_args_from_config_in_group

from delfino_core.config import CorePluginConfig

Expand All @@ -17,7 +18,6 @@ def ensure_reports_dir(config: CorePluginConfig) -> None:
def execute_commands_group(name: str, click_context: click.Context, plugin_config: CorePluginConfig, **kwargs):
root = get_root_command(click_context)
option_name = f"{name}_commands"
passed_args = click_context.params.pop("passed_args", {})

commands: Dict[str, click.Command] = {
command: cast(click.Command, root.get_command(click_context, command))
Expand All @@ -35,7 +35,8 @@ def execute_commands_group(name: str, click_context: click.Context, plugin_confi
_LOG.debug(f"Skipping disabled command '{target_name}'.")
continue

if target_name in passed_args:
click_context.params["passed_args"] = passed_args[target_name]
command = commands[target_name]

click_context.forward(commands[target_name], **kwargs)
set_passed_args_from_config_in_group(click_context, command)

click_context.forward(command, **kwargs)

0 comments on commit a2b8fab

Please sign in to comment.