diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e0dd383..430975c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,23 +1,23 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v5.0.0 hooks: - id: check-added-large-files - id: trailing-whitespace - id: end-of-file-fixer - id: mixed-line-ending - repo: "https://github.com/ambv/black" - rev: 23.1.0 + rev: 25.1.0 hooks: - id: black-jupyter language_version: python3 - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: "v0.0.259" + rev: "v0.11.2" hooks: - id: ruff args: ["--fix"] - repo: https://github.com/pre-commit/mirrors-mypy - rev: "v1.1.1" + rev: "v1.15.0" hooks: - id: mypy additional_dependencies: ["types-PyYAML", "types-requests", "types-setuptools"] diff --git a/markdown_code_runner.py b/markdown_code_runner.py index bb142c6..901426e 100644 --- a/markdown_code_runner.py +++ b/markdown_code_runner.py @@ -35,6 +35,7 @@ echo "Hello, world!" ``` Which will similarly print the output of the code block between next to the output markers. + """ from __future__ import annotations @@ -134,11 +135,12 @@ def execute_code( exec(full_code, context) # noqa: S102 output = string.getvalue().split("\n") elif language == "bash": - result = subprocess.run( + result = subprocess.run( # noqa: S602 full_code, capture_output=True, text=True, shell=True, + check=False, ) output = result.stdout.split("\n") else: @@ -304,6 +306,7 @@ def process_markdown(content: list[str], *, verbose: bool = False) -> list[str]: ------- list[str] A modified list of Markdown-formatted strings with code block output inserted. + """ assert isinstance(content, list), "Input must be a list" state = ProcessingState() diff --git a/tests/test_app.py b/tests/test_app.py index 60c956b..53efd3c 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -1,4 +1,5 @@ """Test the markdown_code_runner app.""" + from __future__ import annotations import argparse @@ -748,10 +749,6 @@ def test_patterns() -> None: ), ("```python markdown-code-runner", {"language": "python"}), ("This is a regular text line", {}), - ( - "```javascript markdown-code-runner filename=test.js", - {"language": "javascript", "filename": "test.js"}, - ), ( "```python markdown-code-runner arg=test.js", {"language": "python", "arg": "test.js"}, @@ -760,10 +757,6 @@ def test_patterns() -> None: "```javascript markdown-code-runner filename=test.js arg2=1", {"language": "javascript", "filename": "test.js", "arg2": "1"}, ), - ( - "```python markdown-code-runner", - {"language": "python"}, - ), ( "```python markdown-code-runner arg1=value1 arg2=value2 arg3=value3", {