8000 chore(project): adopt the recommended ruff thresholds and enforce them in CI by LiinaSuoniemi · Pull Request #74 · habit-hooks/habit-hooks · GitHub
[go: up one dir, main page]

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
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
python-version: "3.11"
- name: Install dependencies
run: uv sync --frozen
- name: Lint (ruff)
run: uv run ruff check src
- name: Setup Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
Expand Down
14 changes: 14 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,17 @@ DEP002 = [
"habit-hooks-typescript",
"habit-hooks-php",
]

[tool.ruff.lint]
# Dogfood the python plugin's recommended structural thresholds
# (plugins/python/src/habit_hooks_python/ruff.toml). extend-select turns the
# three checks on; the blocks below set the limits. Without extend-select the
# thresholds are inert, so both parts are required.
extend-select = ["C901", "PLR0913", "PLR0915"]

[tool.ruff.lint.mccabe]
max-complexity = 10

[tool.ruff.lint.pylint]
max-args = 3
max-statements = 12
9 changes: 4 additions & 5 deletions src/habit_hooks/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,8 @@ def load(name: str) -> str | None:
return Environment(loader=FunctionLoader(load))


def render_markdown(
guide: Path, finding: dict, plugins: list[str], resolver: Resolver
) -> Rendered:
template = include_environment(plugins, resolver).from_string(guide.read_text())
def render_markdown(guide: Path, finding: dict, environment: Environment) -> Rendered:
template = environment.from_string(guide.read_text())
return Rendered(text=template.render(**finding), blocks=True)


Expand All @@ -78,7 +76,8 @@ def render_finding(finding: dict, config: Config, resolver: Resolver) -> Rendere
guide = resolver.guide(UNCOACHED_GUIDE, config.plugins)
extension = guide.suffix.lstrip(".")
if extension == "md":
rendered = render_markdown(guide, finding, config.plugins, resolver)
environment = include_environment(config.plugins, resolver)
rendered = render_markdown(guide, finding, environment)
else:
rendered = render_runner(guide, config.runners[extension], finding)
rendered.blocks = enforced and rendered.blocks
Expand Down
0