diff --git a/.flake8 b/.flake8 index 9fda12eb..b7b1819c 100644 --- a/.flake8 +++ b/.flake8 @@ -1,4 +1,5 @@ [flake8] +max-line-length = 120 extend-ignore = E203,C901 exclude = .git, diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index ce937ed2..00000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Lint - -on: - pull_request: - push: - -jobs: - build: - runs-on: ${{ matrix.os }} - environment: - name: test - strategy: - fail-fast: false - matrix: - python-version: ["3.10"] - os: [ubuntu-latest] - - steps: - - name: Check out Git repository - uses: actions/checkout@v3.4.0 - - - name: set up python '3.10' - uses: actions/setup-python@v4.5.0 - with: - python-version: "3.10" - - # Install your linters here - - name: Install linters - run: | - python -m pip install -e . -r tests/requirements.txt - - - name: Run linters - uses: wearerequired/lint-action@v2.3.0 - with: - flake8: true - continue_on_error: false - # Enable your linters here diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..46245d5a --- /dev/null +++ b/.pre-commit-config.yaml @@ -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"] diff --git a/tests/requirements.txt b/tests/requirements.txt index f0b4f97a..2af89ee7 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -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 diff --git a/tests/test_quality.py b/tests/test_quality.py index 55d424d2..4a4cda29 100644 --- a/tests/test_quality.py +++ b/tests/test_quality.py @@ -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'] diff --git a/tests/test_security.py b/tests/test_security.py index a703e52d..5ca5ddbc 100644 --- a/tests/test_security.py +++ b/tests/test_security.py @@ -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'] @@ -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']