Skip to content

Commit

Permalink
format and lint with black + isort + flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
matin committed Oct 2, 2019
1 parent 570aed4 commit 109d8b4
Show file tree
Hide file tree
Showing 12 changed files with 68 additions and 27 deletions.
25 changes: 16 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
SHELL := bash
DOCKER=docker-compose run --rm speid
PYTHON=python3.7
PATH := ./venv/bin:${PATH}
DOCKER = docker-compose run --rm
PYTHON = python3.7
PROJECT = speid
isort = isort -rc -ac $(PROJECT) tests
black = black -S -l 79 --target-version py37 $(PROJECT) tests



install:
Expand All @@ -12,14 +17,16 @@ install-dev: install
venv:
$(PYTHON) -m venv --prompt speid venv
source venv/bin/activate
pip install --quiet --upgrade pip
pip install -qU pip

lint:
pycodestyle --ignore=E402 speid/ tests/
format:
$(isort)
$(black)

polish:
black -S -l 79 speid/ tests/
isort -rc --atomic speid/ tests/
lint:
flake8 $(PROJECT) tests setup.py
$(isort) --check-only
$(black) --check

clean-pyc:
find . -name '__pycache__' -exec rm -r "{}" +
Expand All @@ -31,7 +38,7 @@ test: clean-pyc lint
coveralls

travis-test:
pip install -q pycodestyle
pip install -q isort black flake8
$(MAKE) lint
$(MAKE) docker-build
$(DOCKER) scripts/test.sh
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
ipython
ipdb
pycodestyle
pytest
pytest-cov
flask-shell-ipython
Expand All @@ -11,4 +10,5 @@ moto
pytest-mock
black
isort[requirements]
flake8
mongomock
8 changes: 8 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[tool:pytest]
addopts = --ignore=src/heimdall/tests -p no:warnings -v --cov-report term-missing --cov=cuenca

[isort]
multi_line_output=3
include_trailing_comma=True
force_grid_wrap=0
combine_as_imports=True
8 changes: 4 additions & 4 deletions speid/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
__all__ = ['commands', 'models', 'views']

import datetime as dt
import json
import os
Expand Down Expand Up @@ -77,9 +79,7 @@ def default(self, o):
empresa=STP_EMPRESA,
priv_key=private_key,
priv_key_passphrase=STP_KEY_PASSPHRASE,
demo=SPEID_ENV is not 'prod',
demo=SPEID_ENV != 'prod',
)

import speid.commands
import speid.models
import speid.views
from . import commands, models, views # noqa: E402 isort:skip
2 changes: 2 additions & 0 deletions speid/commands/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
__all__ = ['docker', 'spei']

from werkzeug.serving import run_simple

from speid import app
Expand Down
2 changes: 2 additions & 0 deletions speid/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
__all__ = ['Event', 'Request', 'Transaction']

from .events import Event
from .requests import Request
from .transaction import Transaction
18 changes: 14 additions & 4 deletions speid/models/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,20 @@
from datetime import datetime
from typing import Union

from mongoengine import (BooleanField, ComplexDateTimeField, DateTimeField,
DecimalField, DictField, Document, EmbeddedDocument,
EmbeddedDocumentField, FloatField, IntField,
ListField, signals)
from mongoengine import (
BooleanField,
ComplexDateTimeField,
DateTimeField,
DecimalField,
DictField,
Document,
EmbeddedDocument,
EmbeddedDocumentField,
FloatField,
IntField,
ListField,
signals,
)
from mongoengine.base import BaseField

_underscorer1 = re.compile(r'(.)([A-Z][a-z]+)')
Expand Down
14 changes: 10 additions & 4 deletions speid/models/transaction.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
from mongoengine import (DateTimeField, Document, IntField, ListField,
ReferenceField, StringField)
from mongoengine import (
DateTimeField,
Document,
IntField,
ListField,
ReferenceField,
StringField,
)
from stpmex import Orden

from speid import STP_EMPRESA
Expand Down Expand Up @@ -68,7 +74,7 @@ def save(
_refs=None,
save_condition=None,
signal_kwargs=None,
**kwargs
**kwargs,
):
if len(self.events) > 0:
[event.save() for event in self.events]
Expand All @@ -82,7 +88,7 @@ def save(
_refs,
save_condition,
signal_kwargs,
**kwargs
**kwargs,
)

def delete(self, signal_kwargs=None, **write_concern):
Expand Down
1 change: 0 additions & 1 deletion speid/tasks/orders.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from speid.types import Estado, EventType
from speid.validations import factory


MAX_AMOUNT = int(os.getenv('MAX_AMOUNT', '9999999999999999'))


Expand Down
2 changes: 2 additions & 0 deletions speid/validations/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
__all__ = ['SpeidTransaction', 'TransactionFactory', 'StpTransaction']

from .speid_transaction import SpeidTransaction
from .speid_transaction_factory import TransactionFactory
from .stp_transaction import StpTransaction
Expand Down
6 changes: 4 additions & 2 deletions tests/commands/test_spei.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import pytest

from speid.commands.spei import (callback_spei_transaction,
re_execute_transactions)
from speid.commands.spei import (
callback_spei_transaction,
re_execute_transactions,
)
from speid.models import Transaction
from speid.types import Estado, EventType

Expand Down
7 changes: 5 additions & 2 deletions tests/helpers/test_callback_helper.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import json
from datetime import datetime

from speid.helpers.callback_helper import (auth_header, send_transaction,
set_status_transaction)
from speid.helpers.callback_helper import (
auth_header,
send_transaction,
set_status_transaction,
)
from speid.models import Transaction


Expand Down

0 comments on commit 109d8b4

Please sign in to comment.