Skip to content

Commit

Permalink
fix: typing
Browse files Browse the repository at this point in the history
  • Loading branch information
sujuka99 committed Sep 26, 2023
1 parent 5dfd27e commit 47155f1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 32 deletions.
2 changes: 1 addition & 1 deletion hooks/gen_docs/gen_docs_env_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def gen_vars(
csv_file: Path,
title_dotenv_file: str,
description_dotenv_file: str,
columns: list,
columns: list[str],
description_md_file: str,
variable_extraction_function: Callable[[Path], None],
) -> None:
Expand Down
60 changes: 29 additions & 31 deletions tests/utils/test_doc_gen.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import TYPE_CHECKING
from pathlib import Path
from typing import Any

import pytest

Expand All @@ -12,13 +13,10 @@
)
from tests.utils.resources.nested_base_settings import ParentSettings

if TYPE_CHECKING:
from pathlib import Path


class TestEnvDocGen:
def test_collect_fields(self):
expected = [
expected: list[Any] = [
"not_nested_field",
"attr",
Ellipsis,
Expand Down Expand Up @@ -66,23 +64,23 @@ def test_collect_fields(self):
)
def test_csv_append_env_var(
self,
tmp_path,
var_name,
default_value,
description,
extra_args,
tmp_path: Path,
var_name: str,
default_value: Any,
description: str | list[str],
extra_args: tuple,
expected_outcome,
):
target: Path = tmp_path / "target.csv"
target = tmp_path / "target.csv"
csv_append_env_var(target, var_name, default_value, description, *extra_args)
with target.open() as t:
assert (
t.read().replace("\r\n", "\n").replace("\r", "\n")
== expected_outcome + "\n"
)

def test_write_title_to_dotenv_file(self, tmp_path):
target: Path = tmp_path / "target.ENV"
def test_write_title_to_dotenv_file(self, tmp_path: Path):
target = tmp_path / "target.ENV"
write_title_to_dotenv_file(target, "title", "description of length 72" * 3)
with target.open() as t:
assert t.read().replace("\r\n", "\n").replace("\r", "\n") == (
Expand All @@ -95,7 +93,7 @@ def test_write_title_to_dotenv_file(self, tmp_path):
)

@pytest.mark.parametrize(
("name", "default", "required", "description", "setting_name", "expected"),
("var_name", "default", "required", "description", "setting_name", "expected"),
[
pytest.param(
"NAME",
Expand Down Expand Up @@ -150,17 +148,17 @@ def test_write_title_to_dotenv_file(self, tmp_path):
)
def test_append_csv_to_dotenv_file(
self,
tmp_path,
name,
default,
required,
description,
setting_name,
expected,
tmp_path: Path,
var_name: str,
default: Any,
required: str,
description: str | list[str],
setting_name: str,
expected: str,
):
source: Path = tmp_path / "source.csv"
target: Path = tmp_path / "target.env"
csv_record = [name, default, required, description]
source = tmp_path / "source.csv"
target = tmp_path / "target.env"
csv_record = [var_name, default, required, description]
csv_column_names = [
EnvVarAttrs.NAME,
EnvVarAttrs.DEFAULT_VALUE,
Expand Down Expand Up @@ -226,14 +224,14 @@ def test_append_csv_to_dotenv_file(
)
def test_write_csv_to_md_file(
self,
tmp_path,
title,
description,
heading,
expected,
tmp_path: Path,
title: str,
description: str,
heading: str,
expected: str,
):
source: Path = tmp_path / "source.csv"
target: Path = tmp_path / "target.env"
source = tmp_path / "source.csv"
target = tmp_path / "target.env"
csv_record = ["NAME", "default", "True", "description", "setting_name"]
csv_column_names = [
EnvVarAttrs.NAME,
Expand Down

0 comments on commit 47155f1

Please sign in to comment.