From 6a0f5096b41624c4cc96874dd672c4e9f4d7268a Mon Sep 17 00:00:00 2001 From: James Prior Date: Fri, 20 Dec 2024 16:51:46 +0000 Subject: [PATCH] Add some workflows --- .github/FUNDING.yml | 1 + .github/workflows/lint.yaml | 17 ++++++++++++ .github/workflows/tests.yaml | 26 +++++++++++++++++++ .github/workflows/typing.yaml | 17 ++++++++++++ liquid2/builtin/filters/__init__.py | 1 + liquid2/builtin/loaders/__init__.py | 1 + liquid2/builtin/loaders/file_system_loader.py | 2 ++ liquid2/builtin/tags/__init__.py | 1 + liquid2/shopify/__init__.py | 1 + liquid2/shopify/tags/__init__.py | 1 + performance/benchmark_001.py | 1 - pyproject.toml | 1 + 12 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 .github/FUNDING.yml create mode 100644 .github/workflows/lint.yaml create mode 100644 .github/workflows/tests.yaml create mode 100644 .github/workflows/typing.yaml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..9b104df --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: jg-rp diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 0000000..337443a --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,17 @@ +name: lint +on: [push, pull_request] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.10 + uses: actions/setup-python@v5 + with: + python-version: "3.10" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install --upgrade hatch + - run: hatch run lint diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 0000000..431378e --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,26 @@ +name: tests +on: [push, pull_request] + +jobs: + tests: + name: ${{ matrix.python-version }} on ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + python-version: ["3.10", "3.11", "3.12", "3.13"] + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install --upgrade hatch + - name: Test + run: hatch run test diff --git a/.github/workflows/typing.yaml b/.github/workflows/typing.yaml new file mode 100644 index 0000000..5283ec6 --- /dev/null +++ b/.github/workflows/typing.yaml @@ -0,0 +1,17 @@ +name: typing +on: [push, pull_request] + +jobs: + typing: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.11 + uses: actions/setup-python@v5 + with: + python-version: "3.11" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install --upgrade hatch + - run: hatch run typing diff --git a/liquid2/builtin/filters/__init__.py b/liquid2/builtin/filters/__init__.py index e69de29..6e03199 100644 --- a/liquid2/builtin/filters/__init__.py +++ b/liquid2/builtin/filters/__init__.py @@ -0,0 +1 @@ +# noqa: D104 diff --git a/liquid2/builtin/loaders/__init__.py b/liquid2/builtin/loaders/__init__.py index e69de29..6e03199 100644 --- a/liquid2/builtin/loaders/__init__.py +++ b/liquid2/builtin/loaders/__init__.py @@ -0,0 +1 @@ +# noqa: D104 diff --git a/liquid2/builtin/loaders/file_system_loader.py b/liquid2/builtin/loaders/file_system_loader.py index 5bb7848..735ee6b 100644 --- a/liquid2/builtin/loaders/file_system_loader.py +++ b/liquid2/builtin/loaders/file_system_loader.py @@ -79,6 +79,7 @@ def get_source( context: RenderContext | None = None, # noqa: ARG002 **kwargs: object, # noqa: ARG002 ) -> TemplateSource: + """Get source information for a template.""" source_path = self.resolve_path(template_name) source, mtime = self._read(source_path) return TemplateSource( @@ -105,6 +106,7 @@ async def get_source_async( context: RenderContext | None = None, # noqa: ARG002 **kwargs: object, # noqa: ARG002 ) -> TemplateSource: + """Get source information for a template.""" loop = asyncio.get_running_loop() source_path = await loop.run_in_executor(None, self.resolve_path, template_name) source, mtime = await loop.run_in_executor(None, self._read, source_path) diff --git a/liquid2/builtin/tags/__init__.py b/liquid2/builtin/tags/__init__.py index e69de29..6e03199 100644 --- a/liquid2/builtin/tags/__init__.py +++ b/liquid2/builtin/tags/__init__.py @@ -0,0 +1 @@ +# noqa: D104 diff --git a/liquid2/shopify/__init__.py b/liquid2/shopify/__init__.py index e69de29..6e03199 100644 --- a/liquid2/shopify/__init__.py +++ b/liquid2/shopify/__init__.py @@ -0,0 +1 @@ +# noqa: D104 diff --git a/liquid2/shopify/tags/__init__.py b/liquid2/shopify/tags/__init__.py index e69de29..6e03199 100644 --- a/liquid2/shopify/tags/__init__.py +++ b/liquid2/shopify/tags/__init__.py @@ -0,0 +1 @@ +# noqa: D104 diff --git a/performance/benchmark_001.py b/performance/benchmark_001.py index 8eaa686..3562024 100644 --- a/performance/benchmark_001.py +++ b/performance/benchmark_001.py @@ -1,4 +1,3 @@ -import sys import timeit from pathlib import Path diff --git a/pyproject.toml b/pyproject.toml index 16c0e95..e729df0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -193,3 +193,4 @@ convention = "google" "liquid2/query/parse.py" = ["D102", "PLR2004"] "liquid2/unescape.py" = ["PLR2004"] "tests/*" = ["D100", "D101", "D104", "D103", "PLR2004", "FBT003"] +"performance/*" = ["D103", "PLR2004", "T201", "D100"]