diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 300b101..9a389fc 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -5,42 +5,41 @@ name: Python package on: push: - branches: [ master ] + branches: [master] pull_request: - branches: [ master ] + branches: [master] jobs: build: - runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.9", "3.10"] + python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"] steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -e ".[test]" - - name: Test with pytest - run: | - pytest --junitxml=junit_report.xml --cov=believe tests - - name: Generate lcov coverage report from .coverage to lcov.info - run: | - coverage-lcov - - name: Export coverage report - uses: romeovs/lcov-reporter-action@v0.2.19 - if: matrix.python-version == '3.9' - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - lcov-file: lcov.info - - name: Publish Unit Test Results - uses: EnricoMi/publish-unit-test-result-action/composite@v1 - if: always() - with: - files: junit_report.xml + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e ".[test]" + - name: Test with pytest + run: | + pytest --junitxml=junit_report.xml --cov=believe tests + - name: Generate lcov coverage report from .coverage to lcov.info + run: | + coverage-lcov + - name: Export coverage report + uses: romeovs/lcov-reporter-action@v0.2.19 + if: matrix.python-version == '3.9' + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + lcov-file: lcov.info + - name: Publish Unit Test Results + uses: EnricoMi/publish-unit-test-result-action/composite@v1 + if: always() + with: + files: junit_report.xml diff --git a/believe/__init__.py b/believe/__init__.py index d21ab4f..a545fcc 100644 --- a/believe/__init__.py +++ b/believe/__init__.py @@ -1,31 +1,26 @@ -from .error import ValidateError - -from .internal import BelieveBase -from .internal import validate - from .dict_matcher import Dict from .dict_matcher import DictOf from .dict_matcher import Optional - -from .list_matcher import OneOf +from .error import ValidateError +from .internal import BelieveBase +from .internal import validate from .list_matcher import AnyOrder from .list_matcher import ListOf - +from .list_matcher import OneOf from .number_matcher import Almost -from .number_matcher import AnyInt from .number_matcher import AnyFloat - -from .other_matcher import Nullable -from .other_matcher import Not +from .number_matcher import AnyInt from .other_matcher import Any - -from .str_matcher import AnyStr +from .other_matcher import Not +from .other_matcher import Nullable from .str_matcher import AnyIntStr +from .str_matcher import AnyIPV4 from .str_matcher import AnyJsonStr +from .str_matcher import AnySHA1 +from .str_matcher import AnyStr from .str_matcher import AnyUrl from .str_matcher import AnyUUID -from .str_matcher import AnyIPV4 -from .str_matcher import AnySHA1 + # Put all Matcher into BelieveMixin class BelieveMixin(object): @@ -39,4 +34,4 @@ class BelieveMixin(object): except TypeError: pass -__version__ = "1.0.12" +__version__ = "1.0.13" diff --git a/believe/dict_matcher.py b/believe/dict_matcher.py index 21aa021..b8bf841 100644 --- a/believe/dict_matcher.py +++ b/believe/dict_matcher.py @@ -1,7 +1,8 @@ import typing + +from .internal import NO_CHECK from .internal import BelieveBase from .internal import validate -from .internal import NO_CHECK class Dict(BelieveBase): diff --git a/believe/error.py b/believe/error.py index 82832eb..1587aea 100644 --- a/believe/error.py +++ b/believe/error.py @@ -1,4 +1,5 @@ -from typing import Any, List +from typing import Any +from typing import List class ValidateError(Exception): diff --git a/believe/internal.py b/believe/internal.py index f703022..3f372cc 100644 --- a/believe/internal.py +++ b/believe/internal.py @@ -1,8 +1,8 @@ import abc import inspect from typing import Any -from .error import ValidateError +from .error import ValidateError # We use Ellipsis to differentiate if caller assign non-default value for kwargs NO_CHECK = USE_DEFAULT = Ellipsis diff --git a/believe/list_matcher.py b/believe/list_matcher.py index 84995e3..b3bc743 100644 --- a/believe/list_matcher.py +++ b/believe/list_matcher.py @@ -1,8 +1,9 @@ -from typing import Any, List +from typing import Any +from typing import List +from .internal import NO_CHECK from .internal import BelieveBase from .internal import validate -from .internal import NO_CHECK class OneOf(BelieveBase): diff --git a/believe/number_matcher.py b/believe/number_matcher.py index ea07c73..2bb20d9 100644 --- a/believe/number_matcher.py +++ b/believe/number_matcher.py @@ -1,6 +1,8 @@ from typing import Union -from .internal import BelieveBase, NO_CHECK, USE_DEFAULT +from .internal import NO_CHECK +from .internal import USE_DEFAULT +from .internal import BelieveBase class Almost(BelieveBase): diff --git a/believe/other_matcher.py b/believe/other_matcher.py index f38e709..725fc4c 100644 --- a/believe/other_matcher.py +++ b/believe/other_matcher.py @@ -1,6 +1,7 @@ -from .internal import BelieveBase from typing import Any +from .internal import BelieveBase + class Nullable(BelieveBase): def __init__(self, obj: Any) -> None: diff --git a/believe/str_matcher.py b/believe/str_matcher.py index 8d81b67..b9d5dbb 100644 --- a/believe/str_matcher.py +++ b/believe/str_matcher.py @@ -1,9 +1,12 @@ -import uuid import json -from typing import Dict, List, Union +import uuid +from typing import Dict +from typing import List +from typing import Union from urllib.parse import urlparse -from .internal import BelieveBase, NO_CHECK +from .internal import NO_CHECK +from .internal import BelieveBase class AnyStr(BelieveBase): diff --git a/pyproject.toml b/pyproject.toml index 6ebe15d..08b4038 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,12 +11,14 @@ classifiers = [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", ] description = "A easy to use validator for json content" -requires-python = '>=3.8' +requires-python = '>=3.6' dynamic = ["version"] keywords = ["json", "validate", "validator"]