Skip to content

Commit

Permalink
include isort make target and travis check
Browse files Browse the repository at this point in the history
  • Loading branch information
monobot committed Mar 20, 2019
1 parent 9c76a71 commit f2a1671
Show file tree
Hide file tree
Showing 24 changed files with 56 additions and 55 deletions.
4 changes: 4 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[settings]
line_length=119
multi_line_output=3
include_trailing_comma=true
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ activate: pipenv shell -c
# command to run tests
script:
- make test
- if [[ $TRAVIS_PYTHON_VERSION == 3.6 ]]; then make lint ; fi
- if [[ $TRAVIS_PYTHON_VERSION == 3.6 ]]; then make lint isort ; fi
33 changes: 19 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ endef
export PRINT_HELP_PYSCRIPT

.PHONY: help
help: ## shows the help menu
help: ## Show the help menu
help:
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)

.PHONY: clean-build
clean-build: ## remove build artifacts
clean-build: ## Remove build artifacts
clean-build:
rm -rf build/
rm -rf dist/
Expand All @@ -26,15 +26,15 @@ clean-build:
find . -name '*.egg' -exec rm -f {} +

.PHONY: clean-pyc
clean-pyc: ## remove Python file artifacts
clean-pyc: ## Remove Python file artifacts
clean-pyc:
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -rf {} +

.PHONY: clean-test
clean-test: ## remove test and coverage artifacts
clean-test: ## Remove test and coverage artifacts
clean-test:
rm -rf .tox/
rm -f .coverage
Expand All @@ -44,54 +44,59 @@ clean-others:
rm -rf .vscode/.ropeproject/

.PHONY: clean
clean: ## remove all build, test, coverage and Python artifacts
clean: ## Remove all build, test, coverage and Python artifacts
clean: clean-build clean-pyc clean-test clean-others

.PHONY: isort
isort: ## Check imports sorting
isort: clean-others
pipenv run isort --diff

.PHONY: lint
lint: ## check style with black code style
lint: ## Check style with black code style
lint: clean-others
pipenv run black --check --diff -l 119 .

setup:
pip install pipenv
pipenv install --dev

test: ## run tests quickly with the default Python
test: ## Run tests quickly with the default Python
pipenv run python -m tests

test-all: ## run tests on every Python version with tox
test-all: ## Run tests on every Python version with tox
pipenv run tox

coverage: ## check code coverage quickly with the default Python
coverage: ## Check code coverage quickly with the default Python
coverage: coverage run --source asyncorm setup.py test
coverage report -m
coverage html
$(BROWSER) htmlcov/index.html

.PHONY: docs
docs: ## generate Sphinx HTML documentation, including API docs
docs: ## Generate Sphinx HTML documentation, including API docs
docs: clean
rm -f docs/asyncorm.rst
rm -f docs/modules.rst
sphinx-apidoc -o docs/ asyncorm
$(MAKE) -C docs clean
$(MAKE) -C docs html

servedocs: ## compile the docs watching for changes
servedocs: ## Compile the docs watching for changes
servedocs: docs
watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D .

release: ## package and upload a release
release: ## Package and upload a release
release: clean
python setup.py sdist upload
python setup.py bdist_wheel upload

dist: ## builds source and wheel package
dist: ## Builds source and wheel package
dist: clean
python setup.py sdist
python setup.py bdist_wheel
ls -l dist

install: ## install the package to the active Python's site-packages
install: ## Install the package to the active Python's site-packages
install: clean
python setup.py install
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pytest-asyncio = "*"
rope = "*"
Sphinx = "*"
tox = ">=3.7.0<3.8"
isort = "*"

[packages]
asyncpg = "==0.18.3"
Expand Down
2 changes: 1 addition & 1 deletion Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion asyncorm/application/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from asyncorm.application.configure import orm_app, configure_orm
from asyncorm.application.configure import configure_orm, orm_app

__all__ = ["orm_app", "configure_orm"]
4 changes: 2 additions & 2 deletions asyncorm/application/commands/migrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import os
import textwrap

from asyncorm.application.configure import configure_orm, DEFAULT_CONFIG_FILE
from asyncorm.application.configure import DEFAULT_CONFIG_FILE, configure_orm
from asyncorm.exceptions import AsyncOrmCommandError, AsyncOrmMigrationError
from asyncorm.orm_migrations.migration_constructor import MigrationConstructor
from asyncorm.migrations.models import AsyncormMigrations
from asyncorm.orm_migrations.migration_constructor import MigrationConstructor

cwd = os.getcwd()

Expand Down
2 changes: 1 addition & 1 deletion asyncorm/application/commands/orm_setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import argparse
import textwrap
import os
import textwrap

from asyncorm.application.configure import DEFAULT_CONFIG_FILE

Expand Down
3 changes: 1 addition & 2 deletions asyncorm/database/backends/postgres_backend.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import asyncpg

from asyncorm.database.backends.sql_base_backend import SQLBaseBackend
from asyncorm.database.cursor import Cursor
from asyncorm.database.query_list import QueryStack
from asyncorm.exceptions import AsyncormTransactionRollback
from asyncorm.log import logger

from asyncorm.database.backends.sql_base_backend import SQLBaseBackend


class PostgresBackend(SQLBaseBackend):
def __init__(self, conn_data):
Expand Down
1 change: 0 additions & 1 deletion asyncorm/log/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logging

from logging.config import dictConfig

LOGLEVEL = "INFO"
Expand Down
2 changes: 1 addition & 1 deletion asyncorm/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
DateTimeField,
DecimalField,
EmailField,
FloatField,
ForeignKey,
GenericIPAddressField,
IntegerField,
FloatField,
JsonField,
MACAdressField,
ManyToManyField,
Expand Down
2 changes: 1 addition & 1 deletion asyncorm/serializers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from asyncorm.serializers.serializer import ModelSerializerMeta, SerializerMethod, ModelSerializer
from asyncorm.serializers.serializer import ModelSerializer, ModelSerializerMeta, SerializerMethod

__all__ = ("ModelSerializerMeta", "SerializerMethod", "ModelSerializer")
3 changes: 2 additions & 1 deletion asyncorm/test_case.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import asyncio
import asyncpg
import os
import unittest

import asyncpg

from asyncorm.application import configure_orm


Expand Down
5 changes: 3 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys
import os
import sys

import asyncorm

# If extensions (or modules to document with autodoc) are in another
# directory, add these directories to sys.path here. If the directory is
Expand All @@ -31,7 +33,6 @@
# version is used.
sys.path.insert(0, project_root)

import asyncorm

# -- General configuration ---------------------------------------------

Expand Down
5 changes: 2 additions & 3 deletions examples/sanic/__main__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from asyncorm.application.configure import configure_orm
from asyncorm.exceptions import QuerysetError
from library.models import Book
from library.serializer import BookSerializer
from sanic import Sanic
from sanic.exceptions import NotFound, URLBuildError
from sanic.response import json
from sanic.views import HTTPMethodView

from library.models import Book
from library.serializer import BookSerializer

app = Sanic(name=__name__)


Expand Down
1 change: 0 additions & 1 deletion examples/sanic/library/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from asyncorm import models


BOOK_CHOICES = (("hard cover", "hard cover book"), ("paperback", "paperback book"))


Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from setuptools import setup

from asyncorm import __version__
Expand Down
5 changes: 2 additions & 3 deletions tests/__main__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import asyncio
import unittest
import os

from tests.app_1.models import Author, Book
import unittest

from asyncorm.application import configure_orm
from tests.app_1.models import Author, Book

config_file = os.path.join(os.getcwd(), "tests", "asyncorm.ini")
orm_app = configure_orm(config_file)
Expand Down
1 change: 0 additions & 1 deletion tests/app_1/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from asyncorm import models


BOOK_CHOICES = (("hard cover", "hard cover book"), ("paperback", "paperback book"))


Expand Down
8 changes: 4 additions & 4 deletions tests/test_fields.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from datetime import date, datetime, time

from uuid import UUID

from netaddr import EUI, IPNetwork, mac_eui48

from asyncorm.exceptions import AsyncormException, AsyncOrmFieldError
from asyncorm import models
from tests.app_1.models import Book, Publisher, Reader, Author
from tests.app_2.models import Organization, Client, Appointment, Skill, Developer
from asyncorm.exceptions import AsyncormException, AsyncOrmFieldError
from asyncorm.test_case import AsyncormTestCase
from tests.app_1.models import Author, Book, Publisher, Reader
from tests.app_2.models import Appointment, Client, Developer, Organization, Skill


class FieldTests(AsyncormTestCase):
Expand Down
12 changes: 5 additions & 7 deletions tests/test_manage.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
from datetime import datetime
from datetime import timedelta
from datetime import datetime, timedelta

from asyncorm.exceptions import (
AsyncOrmModelError,
AsyncOrmModelDoesNotExist,
AsyncOrmQuerysetError,
AsyncOrmModelError,
AsyncOrmMultipleObjectsReturned,
AsyncOrmQuerysetError,
)

from tests.app_1.models import Author, Book
from tests.app_2.models import Appointment, Developer, Client
from asyncorm.test_case import AsyncormTestCase
from tests.app_1.models import Author, Book
from tests.app_2.models import Appointment, Client, Developer


class ManageTestMethods(AsyncormTestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_migration.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from tests.app_1.models import Book
from asyncorm.test_case import AsyncormTestCase
from tests.app_1.models import Book


class MigrationTests(AsyncormTestCase):
Expand Down
5 changes: 2 additions & 3 deletions tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from asyncorm.application.configure import get_model
from asyncorm.exceptions import AsyncOrmFieldError, AsyncOrmModelError

from tests.app_1.models import Book, Author
from tests.app_2.models import Developer, Client, Organization
from asyncorm.test_case import AsyncormTestCase
from tests.app_1.models import Author, Book
from tests.app_2.models import Client, Developer, Organization

# You can get the book by model_name
Book2 = get_model("Book")
Expand Down
5 changes: 2 additions & 3 deletions tests/test_serializers.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from asyncorm.application.configure import get_model
from asyncorm.exceptions import AsyncOrmSerializerError
from asyncorm.serializers import ModelSerializer, SerializerMethod

from tests.app_1.serializer import BookSerializer
from tests.app_1.models import Book, Author
from asyncorm.test_case import AsyncormTestCase
from tests.app_1.models import Author, Book
from tests.app_1.serializer import BookSerializer

# You can get the book by model_name
Book2 = get_model("Book")
Expand Down

0 comments on commit f2a1671

Please sign in to comment.