Skip to content

Commit c004cab

Browse files
authored
Drop Python 3.7 and 3.8 support (#22)
1 parent 5169761 commit c004cab

File tree

2 files changed

+15
-31
lines changed

2 files changed

+15
-31
lines changed

Diff for: markdown_code_runner.py

+11-25
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
```
3737
Which will similarly print the output of the code block between next to the output markers.
3838
"""
39+
3940
from __future__ import annotations
4041

4142
import argparse
@@ -44,30 +45,15 @@
4445
import os
4546
import re
4647
import subprocess
47-
import sys
4848
from dataclasses import dataclass, field
49+
from importlib.metadata import PackageNotFoundError, version
4950
from pathlib import Path
50-
from typing import TYPE_CHECKING, Any
51-
52-
if TYPE_CHECKING:
53-
try:
54-
from typing import Literal # type: ignore[attr-defined]
55-
except ImportError:
56-
from typing_extensions import Literal
57-
58-
59-
if sys.version_info >= (3, 8): # pragma: no cover
60-
from importlib.metadata import PackageNotFoundError, version
61-
62-
try:
63-
__version__ = version("markdown-code-runner")
64-
except PackageNotFoundError:
65-
__version__ = "unknown"
66-
else: # pragma: no cover
67-
import pkg_resources
68-
69-
__version__ = pkg_resources.get_distribution("markdown-code-runner").version
51+
from typing import Any, Literal
7052

53+
try:
54+
__version__ = version("markdown-code-runner")
55+
except PackageNotFoundError: # pragma: no cover
56+
__version__ = "unknown"
7157

7258
DEBUG: bool = os.environ.get("DEBUG", "0") == "1"
7359

@@ -124,7 +110,7 @@ def remove_md_comment(commented_text: str) -> str:
124110
def execute_code(
125111
code: list[str],
126112
context: dict[str, Any] | None = None,
127-
language: Literal["python", "bash"] = None, # type: ignore[name-defined]
113+
language: Literal["python", "bash"] | None = None, # type: ignore[name-defined]
128114
*,
129115
output_file: str | Path | None = None,
130116
verbose: bool = False,
@@ -242,7 +228,7 @@ def _process_start_markers(self, line: str) -> None:
242228
# reset output in case previous output wasn't displayed
243229
self.output = None
244230
self.backtick_options = _extract_backtick_options(line)
245-
self.section, _ = marker.rsplit(":", 1)
231+
self.section, _ = marker.rsplit(":", 1) # type: ignore[assignment]
246232
return
247233

248234
def _process_output_start(self, line: str) -> None:
@@ -268,7 +254,7 @@ def _process_code(
268254
self,
269255
line: str,
270256
end_marker: str,
271-
language: str,
257+
language: Literal["python", "bash"],
272258
*,
273259
remove_comment: bool = False,
274260
verbose: bool,
@@ -293,7 +279,7 @@ def _process_comment_code(self, line: str, *, verbose: bool) -> None:
293279
self._process_code(
294280
line,
295281
"code:comment:end",
296-
language,
282+
language, # type: ignore[arg-type]
297283
remove_comment=True,
298284
verbose=verbose,
299285
)

Diff for: pyproject.toml

+4-6
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ build-backend = "setuptools.build_meta"
66
name = "markdown-code-runner"
77
description = "Automatically execute code blocks within a Markdown file and update the output in-place"
88
authors = [{ name = "Bas Nijholt", email = "[email protected]" }]
9-
dependencies = [
10-
"typing-extensions; python_version < '3.8'",
11-
]
12-
requires-python = ">=3.7"
9+
dependencies = []
10+
requires-python = ">=3.9"
1311
dynamic = ["version"]
1412

1513
[project.readme]
@@ -51,7 +49,7 @@ line_length = 88
5149

5250
[tool.ruff]
5351
line-length = 150
54-
target-version = "py37"
52+
target-version = "py39"
5553
select = ["ALL"]
5654
ignore = [
5755
"T20", # flake8-print
@@ -73,4 +71,4 @@ ignore = [
7371
max-complexity = 18
7472

7573
[tool.mypy]
76-
python_version = "3.7"
74+
python_version = "3.9"

0 commit comments

Comments
 (0)