Read configuration from pyproject.toml
thejcannon opened this issue · 7 comments
Configuring your tool in pyproject.toml
is all the new rage.
Several tools have already added support, and other tools are talking about it.
Feel free to steal ideas from those projects/discussions (such as only considering it as a valid config if the toml
package is installed, which is what isort
does).
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The link to https://github.com/carlosperate/awesome-pyproject is invalid, you're missing a 't' in the end.
This feature would be really good to have and overall leading python ecosystem to a state where one could just have one file configuring dependencies, executables, linter line lengths and tests.
Currently there's direct support from PyLint and wrapper support for Flake8 via Flake9 and FlakeHell.
I think this feature without any more wrapper layers would enable better adoption for new projects whose developers have a idea that they want to try the pyproject.toml
and make their compromises in libraries which don't support it.
Any progress on providing support for pyproject.toml configuration similarly to pytest. Example here ? :)
Hi, any updates on this ? :) Thank's !
It looks like this was added in 8.4.0. Woo hoo!
Did somebody succeed to configure pylama with pyproject.toml file ? I get the following error with 8.4.1, which is 4 months old now. The issue seems to be a pure ProgrammingError (I didn't check in sources)
$ pylama -o pyproject.toml . 130 ↵
Traceback (most recent call last):
File "/home/alorence/.local/bin/pylama", line 8, in <module>
sys.exit(shell())
File "/home/alorence/.local/pipx/venvs/pylama/lib/python3.10/site-packages/pylama/main.py", line 100, in shell
options = parse_options(args)
File "/home/alorence/.local/pipx/venvs/pylama/lib/python3.10/site-packages/pylama/config.py", line 203, in parse_options
cfg = get_config(options.options, rootdir=rootdir)
File "/home/alorence/.local/pipx/venvs/pylama/lib/python3.10/site-packages/pylama/config.py", line 272, in get_config
return get_config_toml(cfg_path)
File "/home/alorence/.local/pipx/venvs/pylama/lib/python3.10/site-packages/pylama/config.py", line 290, in get_config_toml
config = config_toml.Namespace()
NameError: name 'config_toml' is not defined. Did you mean: 'get_config_toml'?
My pyproject.toml:
[tool.pylama]
max_line_length = 120
skip = "*/.pytest_cache/*, */.tox/*, */mypy_cache/*, ./dist, ./docs"
[tool.pylama.linter.mccabe]
max-complexity = 10
@alorence same issue here
It happens because there is some validation at config.py file that tries to import the config_toml module. For some reason, in our environments, the module could not be imported.
config.py
try:
from pylama import config_toml
CONFIG_FILES = ["pylama.ini", "pyproject.toml", "setup.cfg", "tox.ini", "pytest.ini"]
except ImportError:
CONFIG_FILES = ["pylama.ini", "setup.cfg", "tox.ini", "pytest.ini"]
I noticed that the library "toml" is optional, and should be added by perfoming the following command:
pip install pylama[toml]