diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index bfa7ff63..9c96c035 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -11,10 +11,10 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Python 3.9 + - name: Set up Python uses: actions/setup-python@v5 with: - python-version: 3.9 + python-version: 3.10 - name: install pandoc uses: r-lib/actions/setup-pandoc@v2 @@ -27,7 +27,7 @@ jobs: pip install tox - name: Run package benchmarks - run: tox -e py39-bench-packages -- --benchmark-min-rounds 20 --benchmark-json bench-packages.json + run: tox -e py310-bench-packages -- --benchmark-min-rounds 20 --benchmark-json bench-packages.json # - name: Upload package data # uses: actions/upload-artifact@v3 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4d6bf50a..8b0b42b9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,10 +20,10 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Python 3.9 + - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.9' + python-version: '3.10' - uses: pre-commit/action@v3.0.1 tests: @@ -32,7 +32,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['pypy-3.9', '3.9', '3.10', '3.11', '3.12', '3.13'] + python-version: ['pypy-3.10', '3.10', '3.11', '3.12', '3.13'] steps: - uses: actions/checkout@v4 @@ -49,7 +49,7 @@ jobs: run: | pytest tests/ --cov=markdown_it --cov-report=xml --cov-report=term-missing - name: Upload to Codecov - if: matrix.python-version == '3.9' && github.repository == 'executablebooks/markdown-it-py' + if: matrix.python-version == '3.10' && github.repository == 'executablebooks/markdown-it-py' uses: codecov/codecov-action@v5 with: name: markdown-it-py-pytests @@ -63,7 +63,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.9'] + python-version: ['3.10'] steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} @@ -87,10 +87,10 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Python 3.9 + - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.9' + python-version: '3.10' - name: Install tox run: | @@ -98,7 +98,7 @@ jobs: pip install tox - name: Run benchmark - run: tox -e py39-bench-core -- --benchmark-json bench-core.json + run: tox -e py310-bench-core -- --benchmark-json bench-core.json - name: Upload data uses: actions/upload-artifact@v4 @@ -116,10 +116,10 @@ jobs: steps: - name: Checkout source uses: actions/checkout@v4 - - name: Set up Python 3.9 + - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.9' + python-version: '3.10' - name: install flit run: | pip install flit~=3.4 diff --git a/.readthedocs.yml b/.readthedocs.yml index 1faecd92..cb68e005 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -3,7 +3,7 @@ version: 2 build: os: ubuntu-22.04 tools: - python: "3.9" + python: "3.10" python: install: diff --git a/docs/conf.py b/docs/conf.py index 3a40249d..290eac7f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -85,7 +85,7 @@ intersphinx_mapping = { - "python": ("https://docs.python.org/3.9", None), + "python": ("https://docs.python.org/3.10", None), "mdit-py-plugins": ("https://mdit-py-plugins.readthedocs.io/en/latest/", None), } diff --git a/docs/contributing.md b/docs/contributing.md index ea774a8e..eb73ccda 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -50,7 +50,7 @@ This can also be used to run benchmarking tests using [pytest-benchmark](https:/ ```shell >> cd markdown-it-py -tox -e py39-bench-packages -- --benchmark-min-rounds 50 +tox -e py310-bench-packages -- --benchmark-min-rounds 50 ``` For documentation build tests: diff --git a/markdown_it/_compat.py b/markdown_it/_compat.py index 974d431b..9d48db4f 100644 --- a/markdown_it/_compat.py +++ b/markdown_it/_compat.py @@ -1,11 +1 @@ from __future__ import annotations - -from collections.abc import Mapping -import sys -from typing import Any - -DATACLASS_KWARGS: Mapping[str, Any] -if sys.version_info >= (3, 10): - DATACLASS_KWARGS = {"slots": True} -else: - DATACLASS_KWARGS = {} diff --git a/markdown_it/_punycode.py b/markdown_it/_punycode.py index f9baad27..312048bf 100644 --- a/markdown_it/_punycode.py +++ b/markdown_it/_punycode.py @@ -21,8 +21,8 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import codecs +from collections.abc import Callable import re -from typing import Callable REGEX_SEPARATORS = re.compile(r"[\x2E\u3002\uFF0E\uFF61]") REGEX_NON_ASCII = re.compile(r"[^\0-\x7E]") diff --git a/markdown_it/parser_block.py b/markdown_it/parser_block.py index 3c4d4019..50a7184c 100644 --- a/markdown_it/parser_block.py +++ b/markdown_it/parser_block.py @@ -2,8 +2,9 @@ from __future__ import annotations +from collections.abc import Callable import logging -from typing import TYPE_CHECKING, Callable +from typing import TYPE_CHECKING from . import rules_block from .ruler import Ruler diff --git a/markdown_it/parser_core.py b/markdown_it/parser_core.py index 77075098..8f5b921c 100644 --- a/markdown_it/parser_core.py +++ b/markdown_it/parser_core.py @@ -7,7 +7,7 @@ from __future__ import annotations -from typing import Callable +from collections.abc import Callable from .ruler import Ruler from .rules_core import ( diff --git a/markdown_it/parser_inline.py b/markdown_it/parser_inline.py index 8f3ac1e6..26ec2e63 100644 --- a/markdown_it/parser_inline.py +++ b/markdown_it/parser_inline.py @@ -2,7 +2,8 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Callable +from collections.abc import Callable +from typing import TYPE_CHECKING from . import rules_inline from .ruler import Ruler diff --git a/markdown_it/ruler.py b/markdown_it/ruler.py index 711edce7..91ab5804 100644 --- a/markdown_it/ruler.py +++ b/markdown_it/ruler.py @@ -23,8 +23,6 @@ class Ruler from typing import TYPE_CHECKING, Generic, TypedDict, TypeVar import warnings -from markdown_it._compat import DATACLASS_KWARGS - from .utils import EnvType if TYPE_CHECKING: @@ -66,7 +64,7 @@ class RuleOptionsType(TypedDict, total=False): """A rule function, whose signature is dependent on the state type.""" -@dataclass(**DATACLASS_KWARGS) +@dataclass(slots=True) class Rule(Generic[RuleFuncTv]): name: str enabled: bool diff --git a/markdown_it/rules_inline/state_inline.py b/markdown_it/rules_inline/state_inline.py index c0c491c4..ca70294a 100644 --- a/markdown_it/rules_inline/state_inline.py +++ b/markdown_it/rules_inline/state_inline.py @@ -4,7 +4,6 @@ from dataclasses import dataclass from typing import TYPE_CHECKING, Any, Literal -from .._compat import DATACLASS_KWARGS from ..common.utils import isMdAsciiPunct, isPunctChar, isWhiteSpace from ..ruler import StateBase from ..token import Token @@ -14,7 +13,7 @@ from markdown_it import MarkdownIt -@dataclass(**DATACLASS_KWARGS) +@dataclass(slots=True) class Delimiter: # Char code of the starting marker (number). marker: int diff --git a/markdown_it/token.py b/markdown_it/token.py index 90008b72..d6d0b453 100644 --- a/markdown_it/token.py +++ b/markdown_it/token.py @@ -5,8 +5,6 @@ from typing import Any, Literal import warnings -from markdown_it._compat import DATACLASS_KWARGS - def convert_attrs(value: Any) -> Any: """Convert Token.attrs set as ``None`` or ``[[key, value], ...]`` to a dict. @@ -20,7 +18,7 @@ def convert_attrs(value: Any) -> Any: return value -@dc.dataclass(**DATACLASS_KWARGS) +@dc.dataclass(slots=True) class Token: type: str """Type of the token (string, e.g. "paragraph_open")""" diff --git a/markdown_it/utils.py b/markdown_it/utils.py index 3d2a20e5..2571a158 100644 --- a/markdown_it/utils.py +++ b/markdown_it/utils.py @@ -1,9 +1,9 @@ from __future__ import annotations -from collections.abc import Iterable, MutableMapping +from collections.abc import Callable, Iterable, MutableMapping from collections.abc import MutableMapping as MutableMappingABC from pathlib import Path -from typing import TYPE_CHECKING, Any, Callable, TypedDict, cast +from typing import TYPE_CHECKING, Any, TypedDict, cast if TYPE_CHECKING: from typing_extensions import NotRequired diff --git a/pyproject.toml b/pyproject.toml index 5cb7012d..56bd9df2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,6 @@ classifiers = [ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", @@ -25,7 +24,7 @@ classifiers = [ "Topic :: Text Processing :: Markup", ] keywords = ["markdown", "lexer", "parser", "commonmark", "markdown-it"] -requires-python = ">=3.9" +requires-python = ">=3.10" dependencies = [ "mdurl~=0.1", ] diff --git a/tox.ini b/tox.ini index b17bd9d4..f8a9b27e 100644 --- a/tox.ini +++ b/tox.ini @@ -4,18 +4,18 @@ # then run `tox` or `tox -- {pytest args}` # run in parallel using `tox -p` [tox] -envlist = py39 +envlist = py310 [testenv] usedevelop = true -[testenv:py{39,310,311,312,313}] +[testenv:py{310,311,312,313}] extras = linkify testing commands = pytest {posargs:tests/} -[testenv:py{39,310,311,312,313}-plugins] +[testenv:py{310,311,312,313}-plugins] extras = testing changedir = {envtmpdir} allowlist_externals = @@ -27,11 +27,11 @@ commands_pre = commands = pytest {posargs} -[testenv:py{39,310,311,312,313}-bench-core] +[testenv:py{310,311,312,313}-bench-core] extras = benchmarking commands = pytest benchmarking/bench_core.py {posargs} -[testenv:py{39,310,311,312,313}-bench-packages] +[testenv:py{310,311,312,313}-bench-packages] extras = benchmarking,compare commands = pytest benchmarking/bench_packages.py {posargs}