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
6 changes: 5 additions & 1 deletion doc/changes/unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@
* #940: Added shared validation for packaged agent skills and the `skills:check` Nox session.
* #938: Added the `skills:install` Nox session for installing the packaged PTB agent skill.
* #942: Added api-contract-audit skill for identifying mismatches between type annotations, docstrings, and runtime
behavior
behavior

## Refactoring

* #924: Removed the deprecated `lint:dependencies` Nox session and its unused implementation and tests.
76 changes: 0 additions & 76 deletions exasol/toolbox/nox/_lint.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
from __future__ import annotations

import sys
from collections.abc import Iterable
from pathlib import Path

import nox
import rich.console
import tomlkit
from nox import Session

from exasol.toolbox.nox._shared import get_filtered_python_files
from exasol.toolbox.util.dependencies.shared_models import PoetryFiles
from noxconfig import PROJECT_CONFIG

# The relevant nox session will be removed in:
# https://github.com/exasol/python-toolbox/issues/924
LINT_DEPENDENCIES_DEPRECATION_DATE = "2026-10-08"


def _pylint(session: Session, files: Iterable[str]) -> None:
json_file = PROJECT_CONFIG.root_path / ".lint.json"
Expand Down Expand Up @@ -66,58 +57,6 @@ def _security_lint(session: Session, files: Iterable[str]) -> None:
)


class Dependencies:
def __init__(self, illegal: dict[str, list[str]] | None):
self._illegal = illegal or {}

@staticmethod
def parse(pyproject_toml: str) -> Dependencies:
def _source_filter(version) -> bool:
ILLEGAL_SPECIFIERS = ["url", "git", "path"]
return any(specifier in version for specifier in ILLEGAL_SPECIFIERS)

def find_illegal(part) -> list[str]:
return [
f"{name} = {version}"
for name, version in part.items()
if _source_filter(version)
]

illegal: dict[str, list[str]] = {}
toml = tomlkit.loads(pyproject_toml)
poetry = toml.get("tool", {}).get("poetry", {})

part = poetry.get("dependencies", {})
if illegal_group := find_illegal(part):
illegal["tool.poetry.dependencies"] = illegal_group

part = poetry.get("dev", {}).get("dependencies", {})
if illegal_group := find_illegal(part):
illegal["tool.poetry.dev.dependencies"] = illegal_group

part = poetry.get("group", {})
for group, content in part.items():
illegal_group = find_illegal(content.get("dependencies", {}))
if illegal_group:
illegal[f"tool.poetry.group.{group}.dependencies"] = illegal_group
return Dependencies(illegal)

@property
def illegal(self) -> dict[str, list[str]]:
return self._illegal


def report_illegal(illegal: dict[str, list[str]], console: rich.console.Console):
count = sum(len(deps) for deps in illegal.values())
suffix = "y" if count == 1 else "ies"
console.print(f"{count} illegal dependenc{suffix}\n", style="red")
for section, dependencies in illegal.items():
console.print(f"\\[{section}]", style="red")
for dependency in dependencies:
console.print(dependency, style="red")
console.print("")


@nox.session(name="lint:code", python=False)
def lint(session: Session) -> None:
"""Runs the static code analyzer on the project"""
Expand All @@ -137,18 +76,3 @@ def security_lint(session: Session) -> None:
"""Runs the security linter on the project"""
py_files = get_filtered_python_files(PROJECT_CONFIG.source_code_path)
_security_lint(session=session, files=py_files)


@nox.session(name="lint:dependencies", python=False)
def dependency_check(session: Session) -> None:
"""Checks if only valid sources of dependencies are used"""
content = Path(PROJECT_CONFIG.root_path, PoetryFiles.pyproject_toml).read_text()
dependencies = Dependencies.parse(content)
console = rich.console.Console()
if illegal := dependencies.illegal:
report_illegal(illegal, console)
sys.exit(1)
session.warn(
f"Warning: `nox -s lint:dependencies` is deprecated and will be removed on "
f"{LINT_DEPENDENCIES_DEPRECATION_DATE}."
)
174 changes: 0 additions & 174 deletions test/unit/dependencies_check_test.py

This file was deleted.