Skip to content

Commit

Permalink
add pre-commit and apply (#139)
Browse files Browse the repository at this point in the history
* add pre-commit config

* drop wearerequired/lint-action

* fix black config

* disable black

* drop duplicity flake8 check
  • Loading branch information
Borda authored Feb 1, 2024
1 parent e5f2e83 commit 6cfa2c7
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 56 deletions.
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[flake8]
max-line-length = 120
extend-ignore = E203,C901
exclude =
.git,
Expand Down
37 changes: 0 additions & 37 deletions .github/workflows/lint.yml

This file was deleted.

73 changes: 73 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
default_language_version:
python: python3

ci:
autofix_prs: true
autoupdate_commit_msg: "[pre-commit.ci] pre-commit suggestions"
autoupdate_schedule: quarterly
# submodules: true

repos:
# todo: let's enable also al these but as separate PR
# - repo: https://github.com/pre-commit/pre-commit-hooks
# rev: v4.5.0
# hooks:
# - id: end-of-file-fixer
# - id: trailing-whitespace
# - id: check-json
# - id: check-yaml
# - id: check-toml
# - id: check-docstring-first
# - id: check-executables-have-shebangs
# - id: check-case-conflict
# - id: check-added-large-files
# - id: detect-private-key

# todo: another great hook
# - repo: https://github.com/crate-ci/typos
# rev: v1.16.26
# hooks:
# - id: typos
# # empty to do not write fixes
# args: []
# exclude: pyproject.toml

# - repo: https://github.com/PyCQA/docformatter
# rev: v1.7.5
# hooks:
# - id: docformatter
# additional_dependencies: [tomli]
# args: ["--in-place"]

# - repo: https://github.com/psf/black-pre-commit-mirror
# rev: 24.1.1
# hooks:
# - id: black
# name: Format code
# args:
# - "--skip-string-normalization"

# todo: unify formatting all GH actions files
# - repo: https://github.com/pre-commit/mirrors-prettier
# rev: v3.1.0
# hooks:
# - id: prettier
# # https://prettier.io/docs/en/options.html#print-width
# args: ["--print-width=120"]

# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v1.8.0
# hooks:
# - id: mypy

- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8

# todo: replacement for flake8
# - repo: https://github.com/astral-sh/ruff-pre-commit
# rev: v0.1.9
# hooks:
# - id: ruff
# args: ["--fix"]
9 changes: 0 additions & 9 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,6 @@ pytest
coverage
pytest-cov
birch
# linting and code quality; todo: remove after precommint lands
bandit
flake8
pylint
safety
# type checking; todo: remove after precommint lands
mypy
types-setuptools
pandas-stubs
# to connect to the test mongodb server
pymongo
dnspython
Expand Down
9 changes: 1 addition & 8 deletions tests/test_quality.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,7 @@
import subprocess


def test_flake8():
"""Flake8 linter passes with no warnings or errors."""
command = ['flake8']
parameters = ['--max-line-length=120', 'cachier', 'tests']
subprocess.check_call(command + parameters)


@pytest.mark.skip
@pytest.mark.skip # todo: dead check, so let's replace it with Ruff
def test_pylint():
"""Pylint linter passes with no warnings or errors."""
command = ['pylint']
Expand Down
4 changes: 2 additions & 2 deletions tests/test_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import subprocess


@pytest.mark.skip
@pytest.mark.skip # todo: dead check, so let's replace it with Ruff
def test_bandit():
"""Bandit security scan passes with no warnings or errors."""
command = ['bandit']
Expand All @@ -12,7 +12,7 @@ def test_bandit():
subprocess.check_call(command + parameters)


@pytest.mark.skip
@pytest.mark.skip # todo: dead check, so let's enable it in separate PR within pre-commit
def test_safety():
"""Safety security scan passes with no warnings or errors."""
command = ['safety']
Expand Down

0 comments on commit 6cfa2c7

Please sign in to comment.