Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance existing repo with improved meta data #8

Merged
merged 3 commits into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions phulpyfile.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,46 @@
import xml.etree.ElementTree as ET
from os import system, unlink
from os.path import dirname, join

from phulpy import task


@task
def test(phulpy):
phulpy.start(['lint', 'typecheck', 'unit_test'])
phulpy.start(["lint", "typecheck", "unit_test"])


@task
def lint(phulpy):
result = system('flake8 pydantic_mongo')
if result:
raise Exception('lint test failed')
pydantic_mongo_dir = "pydantic_mongo"
for cmd, message in (
(f"flake8 {pydantic_mongo_dir}", "lint test failed"),
(f"isort {pydantic_mongo_dir} --profile black --check", "please run isort!"),
(f"black {pydantic_mongo_dir} --check", "please run black!"),
):
result = system(cmd)
if result:
raise Exception("lint test failed")


@task
def unit_test(phulpy):
result = system(
'pytest --cov-report term-missing'
+ ' --cov-report xml --cov=pydantic_mongo test'
"pytest --cov-report term-missing"
+ " --cov-report xml --cov=pydantic_mongo test"
)
if result:
raise Exception('Unit tests failed')
coverage_path = join(dirname(__file__), 'coverage.xml')
raise Exception("Unit tests failed")
coverage_path = join(dirname(__file__), "coverage.xml")
xml = ET.parse(coverage_path).getroot()
if float(xml.get('line-rate')) < 1:
raise Exception('Unit test is not fully covered')
if float(xml.get("line-rate")) < 1:
raise Exception("Unit test is not fully covered")


@task
def typecheck(phulpy):
result = system(r'find ./pydantic_mongo -name "*.py" -exec mypy --ignore-missing-imports --follow-imports=skip --strict-optional {} \+')
result = system(
r'find ./pydantic_mongo -name "*.py" -exec mypy --ignore-missing-imports --follow-imports=skip --strict-optional {} \+'
)
if result:
raise Exception('lint test failed')
raise Exception("lint test failed")
6 changes: 3 additions & 3 deletions pydantic_mongo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .abstract_repository import AbstractRepository # noqa
from .fields import ObjectIdField # noqa
from .version import __version__ # noqa
from .abstract_repository import AbstractRepository # noqa
from .fields import ObjectIdField # noqa
from .version import __version__ # noqa
Loading