diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 59fef63..5d1db83 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.10', '3.11', '3.12'] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/formatting-and-pyright.yml b/.github/workflows/formatting-and-pyright.yml index be4eec6..ad01b68 100644 --- a/.github/workflows/formatting-and-pyright.yml +++ b/.github/workflows/formatting-and-pyright.yml @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.10'] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v4 diff --git a/filecheck/matcher.py b/filecheck/matcher.py index 5ad4a99..b7ecd63 100644 --- a/filecheck/matcher.py +++ b/filecheck/matcher.py @@ -370,15 +370,14 @@ def _approximate_uop_length(self, uops: Sequence[UOp]) -> int: """ count = 0 for op in uops: - match op: - case Subst(variable): - count += len(str(self.ctx.live_variables.get(variable, ""))) - case Literal(content): - count += len(content) - case RE(content): - count += len(content) - case Capture(pattern): - count += len(pattern) - case _: - continue + if isinstance(op, Subst): + count += len(str(self.ctx.live_variables.get(op.variable, ""))) + elif isinstance(op, Literal): + count += len(op.content) + elif isinstance(op, RE): + count += len(op.content) + elif isinstance(op, Capture): + count += len(op.pattern) + else: + continue return count diff --git a/filecheck/ops.py b/filecheck/ops.py index 2273301..261e31e 100644 --- a/filecheck/ops.py +++ b/filecheck/ops.py @@ -1,13 +1,13 @@ from __future__ import annotations from dataclasses import dataclass, field -from typing import Callable, TypeAlias +from typing import Callable from filecheck.options import Options OP_KINDS = ("DAG", "COUNT", "NOT", "EMPTY", "NEXT", "SAME", "LABEL", "CHECK") -VALUE_MAPPER_T: TypeAlias = Callable[[str], int] | Callable[[str], str] +VALUE_MAPPER_T = Callable[[str], int] | Callable[[str], str] @dataclass(slots=True) diff --git a/poetry.lock b/poetry.lock index 48e7943..07e8ae3 100644 --- a/poetry.lock +++ b/poetry.lock @@ -254,13 +254,13 @@ virtualenv = ">=20.10.0" [[package]] name = "pyright" -version = "1.1.373" +version = "1.1.374" description = "Command line wrapper for pyright" optional = false python-versions = ">=3.7" files = [ - {file = "pyright-1.1.373-py3-none-any.whl", hash = "sha256:b805413227f2c209f27b14b55da27fe5e9fb84129c9f1eb27708a5d12f6f000e"}, - {file = "pyright-1.1.373.tar.gz", hash = "sha256:f41bcfc8b9d1802b09921a394d6ae1ce19694957b628bc657629688daf8a83ff"}, + {file = "pyright-1.1.374-py3-none-any.whl", hash = "sha256:55752bcf7a3646d293cd76710a983b71e16f6128aab2d42468e6eb7e46c0a70d"}, + {file = "pyright-1.1.374.tar.gz", hash = "sha256:d01b2daf864ba5e0362e56b844984865970d7204158e61eb685e2dab7804cb82"}, ] [package.dependencies] @@ -317,6 +317,7 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, + {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, @@ -395,5 +396,5 @@ test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess [metadata] lock-version = "2.0" -python-versions = "^3.10" -content-hash = "b7b972f40548fcf82df353532b2b87f0e9d3680e87dddd2b582c282aa1ecff80" +python-versions = "^3.8" +content-hash = "e531f277074f1e1a005008328c7df1cff22e22ccc8d5a1d5048c3063f5420226" diff --git a/pyproject.toml b/pyproject.toml index 8b04a72..c36297f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,12 +14,12 @@ packages = [ ] [tool.poetry.dependencies] -python = "^3.10" +python = "^3.8" [tool.poetry.group.dev.dependencies] black = "^24.4.2" lit = "^18.1.8" -pre-commit = "^3.7.1" +pre-commit = { version = "^3.7.1", python = "^3.9" } pyright = "^1.1.370" pytest = "^8.2.2"