-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add most_specific_src metadata and export type annotations (#2)
* WIP * WIP
- Loading branch information
Cariad Eccleston
authored
Dec 6, 2020
1 parent
d9d0eb6
commit b024bbe
Showing
14 changed files
with
235 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from pathlib import Path | ||
from typing import List | ||
|
||
from pytest import mark | ||
|
||
from dwalk import dwalk | ||
|
||
project_dir = Path(__file__).parent.parent | ||
testing_dir = project_dir.joinpath("testing") | ||
bottom_dir = testing_dir.joinpath("bottom") | ||
|
||
|
||
def test() -> None: | ||
test_dir = project_dir.joinpath("testing").joinpath("bottom") | ||
actual = dwalk(filenames=["dwalk.2.yml", "dwalk.1.yml"], directory=test_dir) | ||
assert actual == { | ||
"alphabet": {"a": "alpha", "b": "bravo", "c": "charlie", "d": "delta"}, | ||
"favourite_colour": "purple", | ||
"is_bottom_1": True, | ||
"is_bottom_2": True, | ||
"is_top_1": True, | ||
"is_top_2": True, | ||
"shopping_list": ["atari", "bismuth", "cookies"], | ||
"side_count": {"hexagon": 6, "pentagon": 5, "square": 4, "triangle": 3}, | ||
} | ||
|
||
|
||
@mark.parametrize( | ||
"directory, filenames, expect", | ||
[ | ||
( | ||
bottom_dir, | ||
["dwalk.2.yml", "dwalk.1.yml"], | ||
bottom_dir.joinpath("dwalk.1.yml"), | ||
), | ||
(bottom_dir, ["dwalk.3.yml"], testing_dir.joinpath("dwalk.3.yml")), | ||
], | ||
) | ||
def test_most_specific_src(directory: Path, filenames: List[str], expect: Path) -> None: | ||
actual = dwalk(directory=directory, filenames=filenames, include_meta=True) | ||
assert actual["__dwalk__"]["__dwalk__"]["most_specific_src"] == str(expect) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,32 @@ | ||
#!/bin/bash -e | ||
python -m pytest | ||
|
||
echo "Linting YAML..." | ||
yamllint . --strict | ||
|
||
echo "Sorting Python import definitions..." | ||
if [[ "${ci:=}" == "true" ]]; then | ||
isort . --check-only --diff | ||
else | ||
isort . | ||
fi | ||
|
||
echo "Applying opinionated Python code style..." | ||
if [[ "${ci:=}" == "true" ]]; then | ||
black . --check --diff | ||
else | ||
black . | ||
fi | ||
|
||
echo "Checking PEP8 compliance..." | ||
flake8 . | ||
|
||
echo "Checking Python types..." | ||
mypy dwalk | ||
|
||
echo "Testing..." | ||
coverage run | ||
coverage report -m | ||
|
||
if [[ "${ci:=}" != "true" ]]; then | ||
coverage html | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# This property is only in this file: | ||
favourite_sound: jam |
Oops, something went wrong.