This repository has been archived by the owner on Oct 11, 2021. It is now read-only.
-
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.
Merge pull request #1 from binary-butterfly/cleanup-version-0.3
Small cleanups and improvements for version 0.3
- Loading branch information
Showing
65 changed files
with
355 additions
and
274 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[paths] | ||
source = | ||
src | ||
*/site-packages | ||
|
||
[run] | ||
branch = True | ||
source = wtfjson | ||
|
||
[report] | ||
show_missing = True | ||
|
||
[html] | ||
directory = reports/coverage_html/ | ||
skip_empty = True | ||
show_contexts = True |
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 |
---|---|---|
|
@@ -8,6 +8,8 @@ __pycache__/ | |
/venv | ||
/.tox | ||
/.eggs | ||
/.coverage | ||
/build | ||
/dist | ||
/reports | ||
/src/wtfjson.egg-info |
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,26 @@ | ||
.PHONY: all tox open-coverage clean clean-all | ||
|
||
# Default target | ||
all: tox | ||
|
||
|
||
# Test suite | ||
# ---------- | ||
tox: | ||
tox | ||
|
||
flake8: | ||
tox -e flake8 | ||
|
||
# Open HTML coverage report in browser | ||
open-coverage: | ||
$(or $(BROWSER),firefox) ./reports/coverage_html/index.html | ||
|
||
|
||
# Cleanup | ||
# ------- | ||
clean: | ||
rm -rf .coverage reports | ||
|
||
clean-all: clean | ||
rm -rf .tox .eggs venv |
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,3 +1,13 @@ | ||
[pytest] | ||
python_files = *Test.py | ||
addopts = | ||
-ra | ||
--import-mode=importlib | ||
--cov-context=test | ||
--cov-report= | ||
|
||
testpaths = tests | ||
python_files = *_test.py *Test.py | ||
python_classes = *Test | ||
|
||
# Fail on warnings | ||
filterwarnings = error |
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# encoding: utf-8 | ||
|
||
""" | ||
binary butterfly validator | ||
Copyright (c) 2021, binary butterfly GmbH | ||
Use of this source code is governed by an MIT-style license that can be found in the LICENSE.txt. | ||
""" | ||
|
||
from abc import ABC, abstractmethod | ||
|
||
from .exceptions import NotValidated, InvalidData | ||
|
||
|
||
class AbstractInput(ABC): | ||
_errors: dict | ||
_validated: bool = False | ||
|
||
def __init__(self): | ||
self._errors = {} | ||
self._validated = False | ||
|
||
@abstractmethod # pragma: nocover | ||
def validate(self) -> bool: | ||
raise NotImplementedError() | ||
|
||
@property | ||
def has_errors(self) -> bool: | ||
if not self._validated: | ||
raise NotValidated() | ||
return len(self._errors.keys()) > 0 | ||
|
||
@property | ||
def errors(self) -> dict: | ||
if not self._validated: | ||
raise NotValidated() | ||
return self._errors | ||
|
||
def _ensure_validated(self) -> None: | ||
if not self._validated: | ||
raise NotValidated() | ||
if self.has_errors: | ||
raise InvalidData() | ||
|
||
@property | ||
@abstractmethod # pragma: nocover | ||
def data(self): | ||
raise NotImplementedError() | ||
|
||
@property | ||
@abstractmethod # pragma: nocover | ||
def out(self): | ||
raise NotImplementedError() |
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 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
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
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
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
Oops, something went wrong.