pytest-pycodestyle
pytest-pycodestyle copied to clipboard
Configuration file `.pycodestyle.ini` is not loading while `pycodestyle` command is executed.
@henry0312 thank you for this plugin.
Disclaimer
This issue is for expose a behaviour that seems to me is not ok.
Description
Intentionally I create a tiny unit test and a set of rules using the setup.cfg
and .pycodestyle.ini
configuration files.
When setup.cfg
is defined in the project root directory the pycodestyle
work smoothly, when the .pycodestyle.ini
exist in favor of setup.cfg
does not.
I want to undertand why is that, maybe I am doing something out of bounds.
Technical notes
The next lines will expose source code and elements that describe more easily this current issue, at the end you could see the results.
Python version
6f7e8beeb7fd:/app# python3 --version
Python 3.11.8
Python packages installed
6f7e8beeb7fd:/app# pip freeze
iniconfig==2.0.0
kafka-python3==3.0.0
packaging==23.2
pluggy==1.4.0
py==1.11.0
pycodestyle==2.11.1
pydocstyle==6.3.0
pyparsing==3.1.1
pytest==8.1.1
pytest-pycodestyle==2.3.1
pytest-pydocstyle==2.3.2
snowballstemmer==2.2.0
Directory structure
6f7e8beeb7fd:/app# tree
app/
...
tests/
├── __pycache__
│ └── consumer_test.cpython-311-pytest-8.1.1.pyc
└── consumer_test.py
...
.pycodestyle.ini
.pytest.ini
setup.cfg
Configuration files
# Filename: .pycodestyle.ini
# See: https://pycodestyle.pycqa.org/en/latest/intro.html#configuration.
[pycodestyle]
max-line-length = 160
# Filename: setup.cfg
# See: https://pycodestyle.pycqa.org/en/latest/intro.html#configuration.
# See: https://docs.pytest.org/en/latest/reference/customize.html#setup-cfg.
[pycodestyle]
max-line-length = 160
Results
Using .pycodestyle.ini
configuration file
6f7e8beeb7fd:/app# pycodestyle tests/ -vv
directory tests
checking tests/consumer_test.py
from unittest import TestCase
class TestConsumer(TestCase):
"""xxxxxxxxxxxxxxxxxxxxxxxxxxxx"""
def setUp(self) -> None:
pass
def tearDown(self) -> None:
pass
def test_a_non_existent_function(self) -> None:
"""xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"""
self.assertEqual({'xxx': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
tests/consumer_test.py:14:80: E501 line too long (84 > 79 characters)
tests/consumer_test.py:15:80: E501 line too long (101 > 79 characters)
tests/consumer_test.py:18:80: E501 line too long (118 > 79 characters)
tests/consumer_test.py:21:80: E501 line too long (118 > 79 characters)
As you can observe, no configuration file where loaded 🌧️
Using setup.cfg
configuration file
6f7e8beeb7fd:/app# pycodestyle tests/ -vv
local configuration: in /app
max-line-length = 160
directory tests
checking tests/consumer_test.py
from unittest import TestCase
class TestConsumer(TestCase):
"""xxxxxxxxxxxxxxxxxxxxxxxxxxxx"""
def setUp(self) -> None:
pass
def tearDown(self) -> None:
pass
def test_a_non_existent_function(self) -> None:
"""xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"""
self.assertEqual({'xxx': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On the other hand, the configuration is loaded.
Unit test class
from unittest import TestCase
class TestConsumer(TestCase):
"""Cover `TestConsumer` class.`"""
def setUp(self) -> None:
pass
def tearDown(self) -> None:
pass
def test_a_non_existent_function(self) -> None:
"""Unit test to cover a non existent scenario inside the current project."""
# The next extensive lines exist in order to trigger a rule exposed on the `pydocstyle` tool.
self.assertEqual(
{
'key': 'This gonna be a code extensive line to test the `pydocstyle` configuration file: 3.1415926535'
},
{
'key': 'This gonna be a code extensive line to test the `pydocstyle` configuration file: 3.1415926535'
}
)
Thank you for reading it 👋