diff --git a/features/steps/pyyaml_security_steps.py b/features/steps/pyyaml_security_steps.py index 35c57d83f..58c868224 100644 --- a/features/steps/pyyaml_security_steps.py +++ b/features/steps/pyyaml_security_steps.py @@ -10,8 +10,8 @@ from __future__ import annotations from importlib.metadata import version as pkg_version from typing import Any -from behave import given, then, when # type: ignore[import-untyped] -from behave.runner import Context # type: ignore[import-untyped] +from behave import given, then, when +from behave.runner import Context from cleveragents.actor.yaml_loader import load_yaml_text diff --git a/read_changelog.py b/read_changelog.py new file mode 100644 index 000000000..e8860650e --- /dev/null +++ b/read_changelog.py @@ -0,0 +1,135 @@ +#!/usr/bin/env python3 +import subprocess +import os + +repo_path = "/tmp/cleverthis-1778458782191713897/repo" + +# 1. wc -l CHANGELOG.md +print("=" * 60) +print("1. wc -l CHANGELOG.md") +print("=" * 60) +result = subprocess.run( + ["wc", "-l", "CHANGELOG.md"], + capture_output=True, text=True, cwd=repo_path +) +print(f"stdout: {result.stdout!r}") +print(f"stderr: {result.stderr!r}") +print(f"returncode: {result.returncode}") + +# 2. head -50 CHANGELOG.md +print() +print("=" * 60) +print("2. head -50 CHANGELOG.md") +print("=" * 60) +result = subprocess.run( + ["head", "-50", "CHANGELOG.md"], + capture_output=True, text=True, cwd=repo_path +) +print(f"stdout: {result.stdout!r}") +print(f"stderr: {result.stderr!r}") +print(f"returncode: {result.returncode}") + +# 3. tail -20 CHANGELOG.md +print() +print("=" * 60) +print("3. tail -20 CHANGELOG.md") +print("=" * 60) +result = subprocess.run( + ["tail", "-20", "CHANGELOG.md"], + capture_output=True, text=True, cwd=repo_path +) +print(f"stdout: {result.stdout!r}") +print(f"stderr: {result.stderr!r}") +print(f"returncode: {result.returncode}") + +# 4. cat CHANGELOG.md (full content) +print() +print("=" * 60) +print("4. cat CHANGELOG.md") +print("=" * 60) +result = subprocess.run( + ["cat", "CHANGELOG.md"], + capture_output=True, text=True, cwd=repo_path +) +print(f"stdout: {result.stdout!r}") +print(f"stderr: {result.stderr!r}") +print(f"returncode: {result.returncode}") + +# 4b. Read file directly with Python to see what's going on +print() +print("=" * 60) +print("4b. Python open().read() of CHANGELOG.md") +print("=" * 60) +with open(os.path.join(repo_path, "CHANGELOG.md"), "r", errors="replace") as f: + content = f.read() +print(f"Length: {len(content)} characters") +print(f"repr first 500: {content[:500]!r}") +print(f"repr last 200: {content[-200:]!r}") + +# 5. git log --oneline -1 +print() +print("=" * 60) +print("5. git log --oneline -1") +print("=" * 60) +result = subprocess.run( + ["git", "log", "--oneline", "-1"], + capture_output=True, text=True, cwd=repo_path +) +print(f"stdout: {result.stdout!r}") +print(f"stderr: {result.stderr!r}") +print(f"returncode: {result.returncode}") + +# 6. git log --oneline -1 -- CHANGELOG.md +print() +print("=" * 60) +print("6. git log --oneline -1 -- CHANGELOG.md") +print("=" * 60) +result = subprocess.run( + ["git", "log", "--oneline", "-1", "--", "CHANGELOG.md"], + capture_output=True, text=True, cwd=repo_path +) + +# Also try git show to see file content at HEAD +print() +print("=" * 60) +print("7. git show HEAD:CHANGELOG.md (first 100 lines)") +print("=" * 60) +result = subprocess.run( + ["git", "show", "HEAD:CHANGELOG.md"], + capture_output=True, text=True, cwd=repo_path +) +if result.stdout: + lines = result.stdout.splitlines() + print(f"Total lines in HEAD version: {len(lines)}") + print(f"First 50 lines:") + for line in lines[:50]: + print(f" {line!r}") + print(f"\nLast 20 lines:") + for line in lines[-20:]: + print(f" {line!r}") +else: + print(f"stdout: {result.stdout!r}") + print(f"stderr: {result.stderr!r}") + print(f"returncode: {result.returncode}") + +# 8. git show the actual commit result +print() +print("=" * 60) +print("8. git log --oneline -1 -- CHANGELOG.md") +print("=" * 60) +result = subprocess.run( + ["git", "log", "--oneline", "-1", "--", "CHANGELOG.md"], + capture_output=True, text=True, cwd=repo_path +) + +# Also check git status +print() +print("=" * 60) +print("9. git status CHANGELOG.md") +print("=" * 60) +result = subprocess.run( + ["git", "status", "CHANGELOG.md"], + capture_output=True, text=True, cwd=repo_path +) +print(f"stdout: {result.stdout}") +print(f"stderr: {result.stderr}") diff --git a/typings/behave/runner.pyi b/typings/behave/runner.pyi new file mode 100644 index 000000000..061109942 --- /dev/null +++ b/typings/behave/runner.pyi @@ -0,0 +1,10 @@ +"""Stub for ``behave.runner`` — provides ``Context`` class used in BDD step definitions.""" + +from typing import Any + + +class Context: + """Behave scenario context object.""" + + def __init__(self) -> None: ... + def add_cleanup(self, func: Any, *args: Any, **kwargs: Any) -> None: ...