From eb48cf6b2d0de5f97797b7f882d2e59766b9b231 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez=20Mondrag=C3=B3n?= <16805946+edgarrmondragon@users.noreply.github.com> Date: Wed, 2 Oct 2024 14:33:48 -0600 Subject: [PATCH] refactor(templates): Use tox without installing Poetry explicitly in workflows (#2696) * refactor(templates): Use tox without installing Poetry explicitly in workflows * Fix YAML template --- .../.github/workflows/test.yml | 12 +++--------- .../.github/workflows/test.yml | 12 +++--------- .../.github/workflows/test.yml | 12 +++--------- samples/sample_tap_csv/client.py | 5 +++++ 4 files changed, 14 insertions(+), 27 deletions(-) diff --git a/cookiecutter/mapper-template/{{cookiecutter.mapper_id}}/.github/workflows/test.yml b/cookiecutter/mapper-template/{{cookiecutter.mapper_id}}/.github/workflows/test.yml index 929567e8c..fd66735dc 100644 --- a/cookiecutter/mapper-template/{{cookiecutter.mapper_id}}/.github/workflows/test.yml +++ b/cookiecutter/mapper-template/{{cookiecutter.mapper_id}}/.github/workflows/test.yml @@ -44,13 +44,7 @@ jobs: uses: actions/setup-python@v5 with: python-version: {{ '${{ matrix.python-version }}' }} - - name: Install Poetry + - run: pipx install tox + - name: Run Tox run: | - pip install poetry - - name: Install dependencies - run: | - poetry env use {{ '${{ matrix.python-version }}' }} - poetry install - - name: Test with pytest - run: | - poetry run pytest + tox -e $(echo py{{ '${{ matrix.python-version }}' }} | tr -d .) diff --git a/cookiecutter/tap-template/{{cookiecutter.tap_id}}/.github/workflows/test.yml b/cookiecutter/tap-template/{{cookiecutter.tap_id}}/.github/workflows/test.yml index d8772f156..ed9549bca 100644 --- a/cookiecutter/tap-template/{{cookiecutter.tap_id}}/.github/workflows/test.yml +++ b/cookiecutter/tap-template/{{cookiecutter.tap_id}}/.github/workflows/test.yml @@ -44,13 +44,7 @@ jobs: uses: actions/setup-python@v5 with: python-version: {{ '${{ matrix.python-version }}' }} - - name: Install Poetry + - run: pipx install tox + - name: Run Tox run: | - pip install poetry - - name: Install dependencies - run: | - poetry env use {{ '${{ matrix.python-version }}' }} - poetry install - - name: Test with pytest - run: | - poetry run pytest + tox -e $(echo py{{ '${{ matrix.python-version }}' }} | tr -d .) diff --git a/cookiecutter/target-template/{{cookiecutter.target_id}}/.github/workflows/test.yml b/cookiecutter/target-template/{{cookiecutter.target_id}}/.github/workflows/test.yml index 01362f096..9a098a000 100644 --- a/cookiecutter/target-template/{{cookiecutter.target_id}}/.github/workflows/test.yml +++ b/cookiecutter/target-template/{{cookiecutter.target_id}}/.github/workflows/test.yml @@ -44,13 +44,7 @@ jobs: uses: actions/setup-python@v5 with: python-version: {{ '${{ matrix.python-version }}' }} - - name: Install Poetry + - run: pipx install tox + - name: Run Tox run: | - pip install poetry - - name: Install dependencies - run: | - poetry env use {{ '${{ matrix.python-version }}' }} - poetry install - - name: Test with pytest - run: | - poetry run pytest + tox -e $(echo py{{ '${{ matrix.python-version }}' }} | tr -d .) diff --git a/samples/sample_tap_csv/client.py b/samples/sample_tap_csv/client.py index c5a40bfe2..e0767cb19 100644 --- a/samples/sample_tap_csv/client.py +++ b/samples/sample_tap_csv/client.py @@ -1,3 +1,5 @@ +"""Stream class for CSV files.""" + from __future__ import annotations import csv @@ -18,9 +20,11 @@ class CSVStream(FileStream): @property def primary_keys(self) -> t.Sequence[str]: + """Return the primary key fields for records in this stream.""" return (SDC_META_FILEPATH, SDC_META_LINE_NUMBER) def get_schema(self, path: str) -> dict[str, t.Any]: + """Return a schema for the given file.""" with self.filesystem.open(path, mode="r") as file: reader = csv.DictReader( file, @@ -38,6 +42,7 @@ def get_schema(self, path: str) -> dict[str, t.Any]: return schema def read_file(self, path: str) -> t.Iterable[Record]: + """Read the given file and emit records.""" with self.filesystem.open(path, mode="r") as file: reader = csv.DictReader( file,