diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4217dac..23c9d5b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,20 +1,29 @@ repos: - repo: https://github.com/psf/black - rev: 22.6.0 + rev: 23.1.0 hooks: - id: black exclude: ^core/migrations - repo: https://github.com/PyCQA/isort - rev: 5.10.1 + rev: 5.11.5 hooks: - id: isort args: ["--profile", "black"] - repo: https://github.com/PyCQA/flake8 - rev: 4.0.1 + rev: 6.0.0 hooks: - id: flake8 args: [--max-line-length=88] exclude: ^core/migrations + - repo: https://github.com/rtts/djhtml + rev: v2.0.0 + hooks: + - id: djhtml + args: [-t 2] + - id: djcss + exclude : ^core/static/css # slow + - id: djjs + exclude: ^core/static/js # slow - repo: https://github.com/sirwart/ripsecrets.git rev: v0.1.5 hooks: diff --git a/handler/app.py b/handler/app.py index 2e7d995..969858e 100755 --- a/handler/app.py +++ b/handler/app.py @@ -10,12 +10,14 @@ import lib.logstash import lib.markets import lib.money import lib.transactions + # New style classes import sinks import sources import util import ux from klein import Klein + # Project imports from settings import settings from twisted.internet import reactor diff --git a/handler/db.py b/handler/db.py index c899718..dfe9c46 100644 --- a/handler/db.py +++ b/handler/db.py @@ -1,6 +1,7 @@ # Other library imports import util from redis import StrictRedis + # Project imports from settings import settings diff --git a/handler/lib/agoradesk_py.py b/handler/lib/agoradesk_py.py index 9874f90..1b7257d 100644 --- a/handler/lib/agoradesk_py.py +++ b/handler/lib/agoradesk_py.py @@ -7,6 +7,7 @@ from typing import Any, Dict, List, Optional, Union import arrow import treq + # Project imports import util from twisted.internet.defer import inlineCallbacks @@ -675,7 +676,6 @@ class AgoraDesk: amount: Optional[float] = None, page: Optional[int] = None, ) -> Dict[str, Any]: - # pylint: disable=too-many-arguments add_to_api_method = "" diff --git a/handler/lib/localbitcoins_py.py b/handler/lib/localbitcoins_py.py index 2a02b12..ddaad04 100644 --- a/handler/lib/localbitcoins_py.py +++ b/handler/lib/localbitcoins_py.py @@ -13,6 +13,7 @@ from urllib.parse import urlparse import arrow import requests import treq + # Project imports import util from twisted.internet.defer import inlineCallbacks @@ -725,7 +726,6 @@ class LocalBitcoins: amount: Optional[float] = None, page: Optional[int] = None, ) -> Dict[str, Any]: - # pylint: disable=too-many-arguments add_to_api_method = "" diff --git a/handler/lib/logstash.py b/handler/lib/logstash.py index 2aee82d..67cb39b 100644 --- a/handler/lib/logstash.py +++ b/handler/lib/logstash.py @@ -3,6 +3,7 @@ import logging from json import dumps import logstash + # Project imports from settings import settings diff --git a/handler/lib/markets.py b/handler/lib/markets.py index a5eb372..bf9a55a 100644 --- a/handler/lib/markets.py +++ b/handler/lib/markets.py @@ -3,6 +3,7 @@ from json import loads import db import util + # Project imports from settings import settings diff --git a/handler/lib/money.py b/handler/lib/money.py index c385e86..fe888ed 100644 --- a/handler/lib/money.py +++ b/handler/lib/money.py @@ -7,8 +7,10 @@ import util from forex_python.converter import CurrencyRates from lib.logstash import send_logstash from opensearchpy import OpenSearch + # Other library imports from pycoingecko import CoinGeckoAPI + # Project imports from settings import settings from twisted.internet.defer import inlineCallbacks diff --git a/handler/lib/transactions.py b/handler/lib/transactions.py index cfe17ed..72f7d21 100644 --- a/handler/lib/transactions.py +++ b/handler/lib/transactions.py @@ -6,6 +6,7 @@ from string import ascii_uppercase import db import util + # Project imports from settings import settings from twisted.internet.defer import inlineCallbacks diff --git a/handler/sinks/__init__.py b/handler/sinks/__init__.py index 2605fcd..eff0d16 100644 --- a/handler/sinks/__init__.py +++ b/handler/sinks/__init__.py @@ -6,6 +6,7 @@ import sinks.nordigen import sinks.truelayer import util from db import r + # Project imports from settings import settings diff --git a/handler/sinks/nordigen.py b/handler/sinks/nordigen.py index 12dfdb9..d5bfba1 100644 --- a/handler/sinks/nordigen.py +++ b/handler/sinks/nordigen.py @@ -6,10 +6,18 @@ from json import dumps, loads import requests import treq import util -from lib.serde.nordigen import (AccessToken, AccountBalancesRoot, - AccountDetails, Agreement, Institutions, - RequisitionResponse, Requisitions, TXRoot) +from lib.serde.nordigen import ( + AccessToken, + AccountBalancesRoot, + AccountDetails, + Agreement, + Institutions, + RequisitionResponse, + Requisitions, + TXRoot, +) from serde import ValidationError + # Project imports from settings import settings from simplejson.errors import JSONDecodeError diff --git a/handler/sinks/truelayer.py b/handler/sinks/truelayer.py index 9bcfb3b..d5580fe 100644 --- a/handler/sinks/truelayer.py +++ b/handler/sinks/truelayer.py @@ -8,6 +8,7 @@ import requests import util from lib.serde.truelayer import AccountBalancesRoot from serde import ValidationError + # Project imports from settings import settings from simplejson.errors import JSONDecodeError diff --git a/handler/sources/agora.py b/handler/sources/agora.py index a9447a3..ab727b3 100644 --- a/handler/sources/agora.py +++ b/handler/sources/agora.py @@ -1,7 +1,9 @@ # Twisted/Klein imports import sources.local + # Other library imports from pyotp import TOTP + # Project imports from settings import settings from twisted.internet.defer import inlineCallbacks diff --git a/handler/sources/local.py b/handler/sources/local.py index 87b3266..d55acb2 100644 --- a/handler/sources/local.py +++ b/handler/sources/local.py @@ -1,5 +1,6 @@ # Twisted/Klein imports from datetime import datetime + # Other library imports from json import loads from time import sleep # TODO: async @@ -9,6 +10,7 @@ import util from lib.agoradesk_py import AgoraDesk from lib.localbitcoins_py import LocalBitcoins from lib.logstash import send_logstash + # Project imports from settings import settings from twisted.internet.defer import inlineCallbacks diff --git a/handler/sources/localbitcoins.py b/handler/sources/localbitcoins.py index fa08850..5634390 100644 --- a/handler/sources/localbitcoins.py +++ b/handler/sources/localbitcoins.py @@ -2,6 +2,7 @@ import sources.local import util from pyotp import TOTP + # Project imports from settings import settings diff --git a/handler/tests/test_lbtc.py b/handler/tests/test_lbtc.py index fce16c2..85de189 100644 --- a/handler/tests/test_lbtc.py +++ b/handler/tests/test_lbtc.py @@ -10,8 +10,7 @@ import settings import sources import sources.localbitcoins import util -from tests.common import (cg_prices, expected_to_update_lbtc, - fake_public_ads_lbtc) +from tests.common import cg_prices, expected_to_update_lbtc, fake_public_ads_lbtc from twisted.internet.defer import inlineCallbacks diff --git a/handler/util.py b/handler/util.py index e72a64e..08df40d 100644 --- a/handler/util.py +++ b/handler/util.py @@ -3,6 +3,7 @@ import logging from datetime import datetime, timezone from httpx import ReadError, ReadTimeout, RemoteProtocolError + # Project imports from settings import settings @@ -48,7 +49,6 @@ class ColoredFormatter(logging.Formatter): def get_logger(name): - # Define the logging format FORMAT = "%(asctime)s %(levelname)18s $BOLD%(name)13s$RESET - %(message)s" COLOR_FORMAT = formatter_message(FORMAT, True) diff --git a/handler/ux/commands.py b/handler/ux/commands.py index efffa14..7f484f2 100644 --- a/handler/ux/commands.py +++ b/handler/ux/commands.py @@ -2,6 +2,7 @@ from json import dumps, loads import db + # Project imports from settings import settings diff --git a/handler/ux/irc.py b/handler/ux/irc.py index 1c235ac..abdeab7 100644 --- a/handler/ux/irc.py +++ b/handler/ux/irc.py @@ -1,5 +1,6 @@ # Twisted/Klein imports import util + # Project imports from settings import settings from twisted.internet import protocol, reactor, ssl diff --git a/handler/ux/notify.py b/handler/ux/notify.py index ef0fcc0..9071a93 100644 --- a/handler/ux/notify.py +++ b/handler/ux/notify.py @@ -1,6 +1,7 @@ # Other library imports import requests import util + # Project imports from settings import settings diff --git a/handler/ux/verify.py b/handler/ux/verify.py index 94b6a43..156898e 100644 --- a/handler/ux/verify.py +++ b/handler/ux/verify.py @@ -6,6 +6,7 @@ import time import requests import util + # Project imports from settings import settings