Switched to Black-focused config
parent
e044c07cd6
commit
11e5ee2869
1
.flake8
1
.flake8
|
@ -1,5 +1,6 @@
|
||||||
# vim: ft=cfg
|
# vim: ft=cfg
|
||||||
[flake8]
|
[flake8]
|
||||||
|
max-line-length = 88
|
||||||
max-complexity = 7
|
max-complexity = 7
|
||||||
docstring-convention=google
|
docstring-convention=google
|
||||||
|
|
||||||
|
|
7
Makefile
7
Makefile
|
@ -4,7 +4,7 @@ PYTHON := python3
|
||||||
VENV := .venv
|
VENV := .venv
|
||||||
# Minimum % coverage for tests to succeed
|
# Minimum % coverage for tests to succeed
|
||||||
MIN_COV := 50
|
MIN_COV := 50
|
||||||
SRC := setup.py app tests
|
SRC := setup.py config_skeleton tests
|
||||||
|
|
||||||
|
|
||||||
# =====GENERAL=====
|
# =====GENERAL=====
|
||||||
|
@ -34,18 +34,19 @@ venv: $(VENV)/bin/activate
|
||||||
## Formatting & linting
|
## Formatting & linting
|
||||||
### Format the codebase using black
|
### Format the codebase using black
|
||||||
format: venv
|
format: venv
|
||||||
@ '$(VENV)'/bin/black $(SRC)
|
|
||||||
@ '$(VENV)'/bin/isort $(SRC)
|
@ '$(VENV)'/bin/isort $(SRC)
|
||||||
|
@ '$(VENV)'/bin/black $(SRC)
|
||||||
.PHONY: format
|
.PHONY: format
|
||||||
|
|
||||||
### Lint using black & flake8
|
### Lint using black & flake8
|
||||||
lint: venv
|
lint: venv
|
||||||
@ '$(VENV)'/bin/flake8 $(SRC)
|
@ '$(VENV)'/bin/flake8 $(SRC)
|
||||||
@ '$(VENV)'/bin/black --check $(SRC)
|
@ '$(VENV)'/bin/black --check $(SRC)
|
||||||
|
@ '$(VENV)'/bin/isort --check $(SRC)
|
||||||
.PHONY: lint
|
.PHONY: lint
|
||||||
|
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
test: venv
|
test: venv
|
||||||
@ '$(VENV)'/bin/pytest --cov=app --cov-fail-under='$(MIN_COV)' tests/
|
@ '$(VENV)'/bin/pytest --cov=config_skeleton --cov-fail-under='$(MIN_COV)' tests/
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
"""Main module for the app."""
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
"""Main module for the app."""
|
||||||
|
from .exceptions import InvalidKeyError, InvalidValueError, MissingKeyError
|
||||||
|
from .skeleton import merge, merge_with_skeleton
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"InvalidKeyError",
|
||||||
|
"InvalidValueError",
|
||||||
|
"MissingKeyError",
|
||||||
|
"merge",
|
||||||
|
"merge_with_skeleton",
|
||||||
|
]
|
|
@ -48,8 +48,7 @@ class InvalidValueError(Exception):
|
||||||
actual: name of the actual type
|
actual: name of the actual type
|
||||||
"""
|
"""
|
||||||
self.message = (
|
self.message = (
|
||||||
f"Invalid value for key {key}: expected {expected}, "
|
f"Invalid value for key {key}: expected {expected}, " f"got {actual}"
|
||||||
f"got {actual}"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
super().__init__()
|
super().__init__()
|
|
@ -37,9 +37,7 @@ def merge(*dicts: [Dict]) -> Dict:
|
||||||
if type(value) == dict:
|
if type(value) == dict:
|
||||||
# Merge the two sub-dictionaries
|
# Merge the two sub-dictionaries
|
||||||
output[key] = (
|
output[key] = (
|
||||||
merge(output[key], value)
|
merge(output[key], value) if type(output.get(key)) == dict else value
|
||||||
if type(output.get(key)) == dict
|
|
||||||
else value
|
|
||||||
)
|
)
|
||||||
|
|
||||||
else:
|
else:
|
|
@ -2,9 +2,6 @@
|
||||||
requires = ["setuptools", "wheel"]
|
requires = ["setuptools", "wheel"]
|
||||||
build-backend = "setuptools.build_meta"
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
[tool.black]
|
|
||||||
line-length = 79
|
|
||||||
|
|
||||||
[tool.isort]
|
[tool.isort]
|
||||||
profile = "black"
|
profile = "black"
|
||||||
multi_line_output = 3
|
multi_line_output = 3
|
||||||
|
|
|
@ -3,7 +3,7 @@ name = config-skeleton
|
||||||
version = 0.0.1
|
version = 0.0.1
|
||||||
|
|
||||||
[options]
|
[options]
|
||||||
packages = app
|
packages = config_skeleton
|
||||||
install_requires =
|
install_requires =
|
||||||
|
|
||||||
[options.extras_require]
|
[options.extras_require]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
"""Tests for the skeleton module."""
|
"""Tests for the skeleton module."""
|
||||||
from app.skeleton import merge
|
from config_skeleton import merge
|
||||||
|
|
||||||
|
|
||||||
def test_merge_empty():
|
def test_merge_empty():
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
"""Tests wether the skeleton merge works."""
|
"""Tests wether the skeleton merge works."""
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from app.exceptions import InvalidKeyError, MissingKeyError
|
from config_skeleton import InvalidKeyError, MissingKeyError, merge_with_skeleton
|
||||||
from app.skeleton import merge_with_skeleton
|
|
||||||
|
|
||||||
|
|
||||||
def test_single_invalid_key():
|
def test_single_invalid_key():
|
||||||
|
|
Loading…
Reference in New Issue