more pre-commits and makefile

This commit is contained in:
bobokun 2022-11-01 11:24:13 -04:00
parent 7e32ae01f5
commit f4918288b1
No known key found for this signature in database
GPG key ID: B73932169607D927
9 changed files with 47 additions and 18 deletions

View file

@ -23,3 +23,4 @@ test.py
.flake8
qbit_manage.egg-info/
.tox
*.env

10
.flake8
View file

@ -1,13 +1,5 @@
[flake8]
ignore =
E226, # E226 Missing whitespace around arithmetic operator
#E302, # E302 Expected 2 blank lines, found 0
E401, # E401 Multiple imports on one line
E701, # E701 Multiple statements on one line (colon)
E241, # E241 Multiple spaces after ','
E272, # E272 Multiple spaces before keyword
C901, # C901 Function is too complex
extend-ignore =
E722, # E722 Do not use bare except, specify exception instead
W503, # W503 Line break occurred before a binary operator
E402, # E402 module level import not at top of file
max-line-length = 130

1
.gitignore vendored
View file

@ -11,3 +11,4 @@ __pycache__/
.venv*
qbit_manage.egg-info/
.tox
*.env

View file

@ -5,14 +5,21 @@ repos:
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-merge-conflict
- id: check-json
- id: check-yaml
- id: debug-statements
- id: requirements-txt-fixer
- id: check-added-large-files
- id: check-byte-order-marker
- id: fix-encoding-pragma
args: [--remove]
- id: pretty-format-json
args: [--autofix, --indent, '4', --no-sort-keys]
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: v2.0.0
hooks:
- id: autopep8
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.21.0 # or higher tag
hooks:

16
Makefile Normal file
View file

@ -0,0 +1,16 @@
.PHONY: minimal
minimal: venv
venv: requirements.txt setup.py tox.ini
tox -e venv
.PHONY: test
test:
tox
.PHONY: clean
clean:
find -name '*.pyc' -delete
find -name '__pycache__' -delete
rm -rf .tox
rm -rf venv

1
activate.sh Normal file
View file

@ -0,0 +1 @@
venv/bin/activate

1
deactivate.sh Normal file
View file

@ -0,0 +1 @@
deactivate

View file

@ -274,12 +274,12 @@ except ValueError:
logger = MyLogger("qBit Manage", log_file, log_level, default_dir, screen_width, divider[0], False, debug or trace)
from modules import util
from modules import util # noqa
util.logger = logger
from modules.config import Config
from modules.util import GracefulKiller
from modules.util import Failed
from modules.config import Config # noqa
from modules.util import GracefulKiller # noqa
from modules.util import Failed # noqa
def my_except_hook(exctype, value, tb):

20
tox.ini
View file

@ -1,12 +1,22 @@
[tox]
envlist = py39,py310,py311,pre-commit
skip_missing_interpreters = true
tox_pip_extensions_ext_pip_custom_platform = true
tox_pip_extensions_ext_venv_update = true
[testenv]
deps = -r{toxinidir}/requirements.txt
passenv = HOME SSH_AUTH_SOCK USER
commands =
pre-commit install
pre-commit install -f --install-hooks
pre-commit run --all-files --show-diff-on-failure
[testenv:pre-commit]
skip_install = true
deps = pre-commit
commands = pre-commit run --all-files --show-diff-on-failure
[testenv:venv]
envdir = venv
commands =
[flake8]
max-line-length = 130
[pep8]
extend-ignore = E722,E402