Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements-dev.lock
- name: Run tests
run: python -m coverage run -m pytest
run: uv run coverage run -m pytest
- name: Check coverage
run: python -m coverage report --fail-under=100
run: uv run coverage report --fail-under=100
- name: Check types
run: uv run ty check wimsey
19 changes: 17 additions & 2 deletions docs/generate_possible_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
"be": ["column_a", "column_b"],
"not_be": ["column_a", "column_b", "column_c"],
"be_one_of": ["int64", "float64"],
"not_be_one_of": ["a", "b"],
"match_regex": "at$",
}


Expand All @@ -27,7 +29,16 @@ def generate_doc(name: str, doc_string: str, annotations: dict) -> str:
examples["be"] = "int64"
examples["not_be"] = "string"
annotations.pop("return")
dict_eg = {k: examples[k] for k in annotations}
try:
dict_eg = {k: examples[k] for k in annotations}
except KeyError:
msg = (
f"Argument for function {name} can't be generated because it is "
"not in examples within generate_possible_tests arg_examples, consider"
" adding.\n For reference here is the list of attempted examples: "
f"{annotations}"
)
raise KeyError(msg) from KeyError
yaml_eg = yaml.dump({"test": name} | dict_eg)
json_eg = json.dumps({"test": name} | dict_eg, indent=2)
python_eg = f"""
Expand Down Expand Up @@ -71,11 +82,15 @@ def generate_doc(name: str, doc_string: str, annotations: dict) -> str:
"with the exception of where `column` is required."
)
for test_name, test_generator in possible_tests.items():
test_doc_string = test_generator.__doc__
assert isinstance(test_doc_string, str), (
f"{test_generator.__name__} has no docstring, this is required for doc generation"
)
doc = generate_doc(
test_name,
" ".join(test_generator.__doc__.replace("\n", "").split()),
test_generator.__annotations__,
)
file_doc += doc
with open("docs/possible-tests.md", "wt") as file:
with open("docs/possible-tests.md", "w") as file:
file.write(file_doc)
Loading