Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions doc/changes/unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
## Feature

* #691: Started customization of PTB workflows by defining the YML schema

## Refactoring

* #664: Removed deprecation warning for projects to switch over to BaseConfig
2 changes: 0 additions & 2 deletions exasol/toolbox/nox/_artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from nox import Session

from exasol.toolbox.config import BaseConfig
from exasol.toolbox.nox._shared import check_for_config_attribute
from noxconfig import PROJECT_CONFIG

COVERAGE_DB = ".coverage"
Expand Down Expand Up @@ -156,7 +155,6 @@ def copy_artifacts(session: Session) -> None:


def _python_version_suffix() -> str:
check_for_config_attribute(PROJECT_CONFIG, "minimum_python_version")
pivot = PROJECT_CONFIG.minimum_python_version
return f"-python{pivot}"

Expand Down
3 changes: 0 additions & 3 deletions exasol/toolbox/nox/_ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from nox import Session

from exasol.toolbox.config import BaseConfig
from exasol.toolbox.nox._shared import check_for_config_attribute
from noxconfig import (
PROJECT_CONFIG,
)
Expand All @@ -14,12 +13,10 @@


def _python_matrix(config: BaseConfig):
check_for_config_attribute(config=config, attribute="python_versions")
return {"python-version": config.python_versions}


def _exasol_matrix(config: BaseConfig):
check_for_config_attribute(config=config, attribute="exasol_versions")
return {"exasol-version": config.exasol_versions}


Expand Down
2 changes: 0 additions & 2 deletions exasol/toolbox/nox/_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from exasol.toolbox.nox._shared import (
Mode,
_version,
check_for_config_attribute,
get_filtered_python_files,
)
from noxconfig import (
Expand All @@ -26,7 +25,6 @@ def command(*args: str) -> Iterable[str]:


def _pyupgrade(session: Session, config: BaseConfig, files: Iterable[str]) -> None:
check_for_config_attribute(config, "pyupgrade_argument")
session.run(
"pyupgrade",
*config.pyupgrade_argument,
Expand Down
2 changes: 0 additions & 2 deletions exasol/toolbox/nox/_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from exasol.toolbox.nox._shared import (
Mode,
_version,
check_for_config_attribute,
)
from exasol.toolbox.nox.plugin import NoxTasks
from exasol.toolbox.util.dependencies.shared_models import PoetryFiles
Expand Down Expand Up @@ -103,7 +102,6 @@ def run(*args: str):
run("git", "tag", str(release_version))
run("git", "push", "origin", str(release_version))

check_for_config_attribute(project_config, "create_major_version_tags")
if project_config.create_major_version_tags:
major_release_version = f"v{release_version.major}"
run("git", "tag", "-f", str(major_release_version))
Expand Down
13 changes: 0 additions & 13 deletions exasol/toolbox/nox/_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,13 @@

from nox import Session

from exasol.toolbox.config import BaseConfig
from noxconfig import (
PROJECT_CONFIG,
)

DOCS_OUTPUT_DIR = ".html-documentation"


def check_for_config_attribute(config: BaseConfig, attribute: str):
if not hasattr(config, attribute):
raise AttributeError(
"in the noxconfig.py file, the class Config should inherit "
"from `exasol.toolbox.config.BaseConfig`. This is used to "
f"set the default `{attribute}`. If the allowed "
f"`{attribute} needs to differ in your project and is an "
"input parameter (not property), you can set it in the PROJECT_CONFIG statement."
)


class Mode(Enum):
Fix = auto()
Check = auto()
Expand All @@ -42,7 +30,6 @@ def get_filtered_python_files(project_root: Path) -> list[str]:
"""
Returns iterable of Python files after removing excluded paths
"""
check_for_config_attribute(config=PROJECT_CONFIG, attribute="excluded_python_paths")
files = project_root.glob("**/*.py")
return [
f"{path}"
Expand Down
41 changes: 0 additions & 41 deletions test/unit/nox/_shared_test.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
from collections.abc import Iterable
from dataclasses import dataclass
from pathlib import Path
from unittest.mock import patch

import pytest

from exasol.toolbox.config import BaseConfig
from exasol.toolbox.nox._shared import (
check_for_config_attribute,
get_filtered_python_files,
)

Expand Down Expand Up @@ -64,39 +59,3 @@ def test_get_filtered_python_files(

assert len(actual) == 1
assert "toolbox-dummy" in actual[0]


@dataclass(frozen=True)
class PreviousConfig:
root: Path = Path(__file__).parent
doc: Path = Path(__file__).parent / "doc"
source: Path = Path("exasol/toolbox")
version_file: Path = Path(__file__).parent / "exasol" / "toolbox" / "version.py"
path_filters: Iterable[str] = ()
pyupgrade_args: Iterable[str] = ("--py310-plus",)
plugins = []


# attributes + properties
MIGRATED_VALUES = [
*BaseConfig.model_fields.keys(),
*BaseConfig.model_computed_fields.keys(),
]


class TestCheckForConfigAttribute:

@pytest.mark.parametrize("attribute", MIGRATED_VALUES)
def test_old_implementation_raises_error(self, attribute):
with pytest.raises(
AttributeError, match="from `exasol.toolbox.config.BaseConfig`"
):
check_for_config_attribute(PreviousConfig(), attribute=attribute)

@pytest.mark.parametrize("attribute", MIGRATED_VALUES)
def test_current_implementation_passes(
self, test_project_config_factory, attribute
):
check_for_config_attribute(
config=test_project_config_factory(), attribute=attribute
)