Skip to content

Commit 774a176

Browse files
mkrannapre-commit-ci[bot]edgarrmondragon
authored
feat: Cookiecutter target tox ini (#1438)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Edgar R. M <[email protected]>
1 parent 6ebc5ee commit 774a176

File tree

2 files changed

+70
-2
lines changed
  • cookiecutter/target-template/{{cookiecutter.target_id}}

2 files changed

+70
-2
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# This file can be used to customize tox tests as well as other test frameworks like flake8 and mypy
2+
3+
[tox]
4+
envlist = py38
5+
; envlist = py37, py38, py39
6+
isolated_build = true
7+
8+
[testenv]
9+
allowlist_externals = poetry
10+
11+
commands =
12+
poetry install -v
13+
poetry run pytest
14+
poetry run black --check {{cookiecutter.library_name}}/
15+
poetry run flake8 {{cookiecutter.library_name}}
16+
poetry run mypy {{cookiecutter.library_name}} --exclude='{{cookiecutter.library_name}}/tests'
17+
18+
[testenv:pytest]
19+
# Run the python tests.
20+
# To execute, run `tox -e pytest`
21+
envlist = py37, py38, py39
22+
commands =
23+
poetry install -v
24+
poetry run pytest
25+
26+
[testenv:format]
27+
# Attempt to auto-resolve lint errors before they are raised.
28+
# To execute, run `tox -e format`
29+
commands =
30+
poetry install -v
31+
poetry run black {{cookiecutter.library_name}}/
32+
poetry run isort {{cookiecutter.library_name}}
33+
34+
[testenv:lint]
35+
# Raise an error if lint and style standards are not met.
36+
# To execute, run `tox -e lint`
37+
commands =
38+
poetry install -v
39+
poetry run black --check --diff {{cookiecutter.library_name}}/
40+
poetry run isort --check {{cookiecutter.library_name}}
41+
poetry run flake8 {{cookiecutter.library_name}}
42+
# refer to mypy.ini for specific settings
43+
poetry run mypy {{cookiecutter.library_name}} --exclude='{{cookiecutter.library_name}}/tests'
44+
45+
[flake8]
46+
docstring-convention = google
47+
ignore = W503
48+
max-line-length = 88
49+
max-complexity = 10
50+
51+
[pydocstyle]
52+
ignore = D105,D203,D213

cookiecutter/target-template/{{cookiecutter.target_id}}/{{cookiecutter.library_name}}/sinks.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ class {{ cookiecutter.destination_name }}Sink({{ sinkclass }}):
4747

4848
{% if sinkclass == "RecordSink" -%}
4949
def process_record(self, record: dict, context: dict) -> None:
50-
"""Process the record."""
50+
"""Process the record.
51+
52+
Args:
53+
record: Individual record in the stream.
54+
context: Stream partition or context dictionary.
55+
"""
5156
# Sample:
5257
# ------
5358
# client.write(record)
@@ -61,6 +66,9 @@ def start_batch(self, context: dict) -> None:
6166
6267
Developers may optionally add additional markers to the `context` dict,
6368
which is unique to this batch.
69+
70+
Args:
71+
context: Stream partition or context dictionary.
6472
"""
6573
# Sample:
6674
# ------
@@ -72,14 +80,22 @@ def process_record(self, record: dict, context: dict) -> None:
7280
7381
Developers may optionally read or write additional markers within the
7482
passed `context` dict from the current batch.
83+
84+
Args:
85+
record: Individual record in the stream.
86+
context: Stream partition or context dictionary.
7587
"""
7688
# Sample:
7789
# ------
7890
# with open(context["file_path"], "a") as csvfile:
7991
# csvfile.write(record)
8092

8193
def process_batch(self, context: dict) -> None:
82-
"""Write out any prepped records and return once fully written."""
94+
"""Write out any prepped records and return once fully written.
95+
96+
Args:
97+
context: Stream partition or context dictionary.
98+
"""
8399
# Sample:
84100
# ------
85101
# client.upload(context["file_path"]) # Upload file

0 commit comments

Comments
 (0)