Skip to content

pylint more restrictive in pre-commit than in tox #1061

@dkrako

Description

@dkrako

Current Behavior

Linting the tests directory is much more restrictive in the local pre-commit hook than it is in the tox environment (which is used by the github workflow).

Expected Behavior

The github workflow should be as restrictive as the pre-commit hook.

Context

Here is the pre-commit definition:

- id: pylint
name: pylint-tests-directory
entry: pylint
language: system
types: [python]
files: ^tests/
args:
[
'--output-format=parseable',
'--disable=duplicate-code',
'--disable=missing-class-docstring',
'--disable=missing-function-docstring',
'--disable=protected-access',
'--rcfile=pylintrc',
]

and here's the one in tox:

pymovements/tox.ini

Lines 88 to 97 in 6245bbf

[testenv:pylint]
deps =
pylint
pytest
changedir = {toxinidir}
commands =
pylint --rcfile=pylintrc --output-format=parseable --ignore-paths={toxinidir}/src/pymovements/_version.py \
{toxinidir}/src/pymovements
pylint --rcfile=pylintrc --output-format=parseable \
--disable=missing-class-docstring,missing-function-docstring,protected-access {toxinidir}/tests

The pre-commit definition is actually less restrictive, because it allows for duplicate code. They both use the pylintrc config. How can this be?

Steps to Reproduce

  1. Add a comment line that's longer than 120 characters to one of the test files.

  2. Add file change to git via git add tests

  3. run pylint using pre-commit

$ pre-commit run pylint
pylint...............................................(no files to check)Skipped
pylint-tests-directory...................................................Failed
- hook id: pylint
- exit code: 16

************* Module dataset_download_test
tests/unit/dataset/dataset_download_test.py:1375: [C0301(line-too-long), ] Line too long (133/100)

-------------------------------------------------------------------
Your code has been rated at 9.96/10 (previous run: 10.00/10, -0.04)
  1. run pylint using tox
$ tox -e pylint
.pkg: _optional_hooks> python /usr/lib/python3.13/site-packages/pyproject_api/_backend.py True setuptools.build_meta
.pkg: get_requires_for_build_sdist> python /usr/lib/python3.13/site-packages/pyproject_api/_backend.py True setuptools.build_meta
.pkg: build_sdist> python /usr/lib/python3.13/site-packages/pyproject_api/_backend.py True setuptools.build_meta
pylint: install_package> python -I -m pip install --force-reinstall --no-deps /home/krakowczyk/workspace/pymovements/.tox/.tmp/package/207/pymovements-0.21.0.post26+git.750b78e0.dirty.tar.gz
pylint: commands[0]> pylint --rcfile=pylintrc --output-format=parseable --ignore-paths=/home/krakowczyk/workspace/pymovements/src/pymovements/_version.py /home/krakowczyk/workspace/pymovements/src/pymovements

--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

pylint: commands[1]> pylint --rcfile=pylintrc --output-format=parseable --disable=missing-class-docstring,missing-function-docstring,protected-access /home/krakowczyk/workspace/pymovements/tests
  pylint: OK (36.01=setup[5.26]+cmd[30.03,0.73] seconds)
  congratulations :) (36.12 seconds)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions