Skip to content

Commit

Permalink
Merge pull request #4 from pkyosx/feat/porting_3_6
Browse files Browse the repository at this point in the history
feat: support older version of python
  • Loading branch information
pkyosx authored May 6, 2022
2 parents 8a92aa4 + f6a6d59 commit eaea29c
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 58 deletions.
59 changes: 29 additions & 30 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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/[email protected]
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
29 changes: 12 additions & 17 deletions believe/__init__.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -39,4 +34,4 @@ class BelieveMixin(object):
except TypeError:
pass

__version__ = "1.0.12"
__version__ = "1.0.13"
3 changes: 2 additions & 1 deletion believe/dict_matcher.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
3 changes: 2 additions & 1 deletion believe/error.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any, List
from typing import Any
from typing import List


class ValidateError(Exception):
Expand Down
2 changes: 1 addition & 1 deletion believe/internal.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 3 additions & 2 deletions believe/list_matcher.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
4 changes: 3 additions & 1 deletion believe/number_matcher.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
3 changes: 2 additions & 1 deletion believe/other_matcher.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
9 changes: 6 additions & 3 deletions believe/str_matcher.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down

1 comment on commit eaea29c

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage for this commit

98.69%

Coverage Report
FileBranchesFuncsLinesUncovered Lines
believe
   __init__.py100%100%100%
   dict_matcher.py100%100%100%
   error.py100%100%100%
   internal.py100%100%97.62%49
   list_matcher.py100%100%96.23%30, 36
   number_matcher.py100%100%100%
   other_matcher.py100%100%100%
   str_matcher.py100%100%98.11%55–56

Please sign in to comment.