diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..f3f5370 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,25 @@ +# Defines coding style rules for most editors and IDEs +# See: https://editorconfig.org + +root = true + +[*] +end_of_line = lf +charset = utf-8 +insert_final_newline = true +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +[*.{json,html,xml,yml,yaml}] +indent_size = 2 + +[*.csv] +end_of_line = crlf +trim_trailing_whitespace = false + +[*.md] +trim_trailing_whitespace = false + +[Makefile] +indent_style = tab diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0df55ff --- /dev/null +++ b/.gitignore @@ -0,0 +1,20 @@ +# Logs, data, and other cruft +*~ +.~lock*# +\#* +.\#* +*.log +*.pyc +__pycache__ +/.idea + +# Tests and metrics +/junit.xml +/.coverage +/coverage.xml +/.pytest_cache +/.tox/ + +# Virtual environments +/venv/ +/.venv/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..6ef46b4 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,30 @@ +fail_fast: false +repos: + # Are we accidentally committing secrets, keys, credentials, etc.? + - repo: https://github.com/gitleaks/gitleaks + rev: v8.18.4 + hooks: + - id: gitleaks + + # Check for simple quick low-hanging fruit + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + # Does it parse? + - id: check-ast + - id: check-json + - id: check-toml + - id: check-yaml + # Have we accidentally left merge markers in? + - id: check-merge-conflict + # Fix BOM, EOF whitespace + - id: fix-byte-order-marker + - id: end-of-file-fixer + +# Auto-format some non-controversial PEP8 things + - repo: https://github.com/hhatto/autopep8 + rev: v2.3.1 + hooks: + - id: autopep8 + # fix blank lines between classes and funcs, import lines, trailing whitespace + args: ["--in-place", "--select", "E301,E302,E303,E304,E305,E306,E401,W291,W292,W293,W391"] diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..75c9fcd --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,17 @@ +[tool.isort] +line_length = 120 +multi_line_output = 5 +skip = [] +known_first_party = [] + +[tool.flake8] +max_line_length = 120 +exclude = [ ".git", ".pytest_cache", ".tox", ".venv", "__pycache__", "venv" ] +ignore = [ "E501" ] + +[tool.autopep8] +max_line_length = 120 +ignore = [ "E501" ] +in-place = true +recursive = true +aggressive = 3 diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..8e93fd2 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,5 @@ +[pytest] +minversion = 8.0 +norecursedirs = venv .venv .git *.egg .* build dist +python_files = tests.py test_*.py *_tests.py +pythonpath = . diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..1e67d9d --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,13 @@ +-r requirements.txt + +# Code lint +autopep8 +flake8 + +# Security +pre-commit + +# Unit tests and coverage +pytest +pytest-cov +tox diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e69de29 diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..3a0eecb --- /dev/null +++ b/tox.ini @@ -0,0 +1,29 @@ +[tox] +envlist = py38,py310 +skipsdist = True +skip_missing_interpreters = True + +[testenv] +skip_install = True +setenv = + PYTHONPATH = {toxroot} +commands = + pytest --cov=. --junitxml=junit.xml --cov-report xml:coverage.xml --cov-report term {posargs} +deps = + -r requirements-dev.txt + +[coverage:run] + +[coverage:report] +skip_empty = True +sort = miss + +[flake8] +max_line_length = 120 +ignore = E501 +exclude = + .git, + .pytest_cache, + .tox, + .venv, + venv