Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read configuration from pyproject.toml #171

Open
thejcannon opened this issue Feb 4, 2020 · 7 comments
Open

Read configuration from pyproject.toml #171

thejcannon opened this issue Feb 4, 2020 · 7 comments

Comments

@thejcannon
Copy link

thejcannon commented Feb 4, 2020

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.

@Jaakkonen
Copy link

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.

@nico-unity
Copy link

Any progress on providing support for pyproject.toml configuration similarly to pytest. Example here ? :)

@gmolveau
Copy link

gmolveau commented May 9, 2022

Hi, any updates on this ? :) Thank's !

@KevinMGranger
Copy link

It looks like this was added in 8.4.0. Woo hoo!

@alorence
Copy link

alorence commented Nov 29, 2022

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

@vinibiavatti1
Copy link

vinibiavatti1 commented Jan 31, 2023

@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"]

@vinibiavatti1
Copy link

vinibiavatti1 commented Jan 31, 2023

I noticed that the library "toml" is optional, and should be added by perfoming the following command:

pip install pylama[toml]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants