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

Support loading options from a configuration file (pyproject.toml?) #164

Closed
Varriount opened this issue Jul 12, 2019 · 18 comments
Closed

Support loading options from a configuration file (pyproject.toml?) #164

Varriount opened this issue Jul 12, 2019 · 18 comments

Comments

@Varriount
Copy link

It would be nice if vulture supported using setup.cfg/setup.ini to retrieve whitelists, exclusions, etc. from.

@RJ722
Copy link
Contributor

RJ722 commented Jul 17, 2019

Hi @Varriount,

Thanks for the feedback, but I'm not sure that I entirely get what you're trying to say. Can you give an example of what exactly are you asking for, please?

@tarkatronic
Copy link

Alternatively, perhaps pyproject.toml support would be good, as this is becoming The Way for configuration in the Python world. An example entry for vulture might look like:

[tool.vulture]
min-confidence = 70
exclude = ".eggs,.git,.*cache,.tox,.venv,build,dist"

This would allow a user to have more determinism in their vulture runs, since they would not have to specify command line options every time.

I recently implemented this in tartufo, based heavily on the work in black.

This style of configuration is being adopted in many other large Python tools. A list of other tools can be found here: https://github.com/flying-sheep/awesome-python-packaging

In addition, mypy will be adding support as well.

@jendrikseipp
Copy link
Owner

@tarkatronic sounds interesting! It would be awesome if you could make a pull request.

@jendrikseipp jendrikseipp changed the title setup.cfg/setup.ini support Support pyproject.toml Nov 19, 2019
@RJ722
Copy link
Contributor

RJ722 commented Dec 28, 2019

@jendrikseipp I can work on this. However, adding support for pyproject.toml would mean having an external dependency toml. Are you okay with it?

@jendrikseipp
Copy link
Owner

Good point. I'm not sure. Having no external dependencies certainly has appeal. Also, it's not clear which TOML library we should use (there are 3 Python TOML libraries). Maybe we should defer this issue until the dust has settled on how to declare options for linters and similar tools.

@jendrikseipp
Copy link
Owner

I guess we could make the TOML dependency optional like isort does. Still, it's not clear which TOML library to use.

@RJ722
Copy link
Contributor

RJ722 commented Mar 10, 2020

https://pypi.org/project/toml/ seems to be the standard and most popular (more than 18k users according to https://github.com/uiri/toml)

@jendrikseipp
Copy link
Owner

I checked which projects use which toml library:

  • toml: black, isort, mypy (WIP)
  • tomlkit: poetry

So it seems "toml" is indeed the way to go. Especially, since we only need to load TOML, not modify it.

@jendrikseipp
Copy link
Owner

isort now bundles a vendorized copy of toml. We could probably do the same.

@exhuma
Copy link
Contributor

exhuma commented Jul 8, 2020

Having some configuration support would be helpful for CI pipelines as well. Until recently I have been in the camp being "against yet another dependency" just for project development support like TOML. But a recent episode on a podcast changed my mind about this... let me find it back... here it is.

I would be willing to work on this if you let me know which way you'd like to go. I see either pyproject.toml with a vendored parser or a simple .ini file. I'm not all too opposed to adding a real dependency for a TOML parser instead of vendoring but I am leaning more towards vendoring too.

@jendrikseipp let me know if you want me to go ahead with one of those solutions.

@exhuma
Copy link
Contributor

exhuma commented Jul 8, 2020

nb, this issue might benefit from a better subject. The primary topic is the be able to have config-values in a config file in addition to the cli-args. Might help others find it a bit better.

@jendrikseipp jendrikseipp changed the title Support pyproject.toml Support loading options from a configuration file (pyproject.toml?) Jul 9, 2020
@jendrikseipp
Copy link
Owner

@exhuma thanks for the link! I'll listen to the episode and will get back to you on this.

@exhuma
Copy link
Contributor

exhuma commented Jul 11, 2020

@jendrikseipp I will likely start to dabble around with it tomorrow, just to familiarise myself with the project structure of vulture and toml. I don't mind if I need to rewrite that work as my main aim will be the aforementioned familiarisation 😉 If I'm happy with the result I'll open a PR, and you can go nutters with the review. I have a thick skin and am always fairly critical in reviews I do myself, so you don't need to worry about scaring me away 😉

@jendrikseipp
Copy link
Owner

@exhuma Sounds great! I listened to the podcast and think that the best solution is to add a dependency on toml. I recommend looking at how other projects use toml and pyproject.toml (e.g., black) to avoid reinventing the wheel :-)

@exhuma
Copy link
Contributor

exhuma commented Jul 11, 2020

I recommend looking at how other projects use toml and pyproject.toml (e.g., black) to avoid reinventing the wheel :-)

will do

@exhuma
Copy link
Contributor

exhuma commented Jul 12, 2020

Done. Let me know what you think :)

@RJ722
Copy link
Contributor

RJ722 commented Sep 26, 2020

Now that #215 has merged, let's close this?

@jendrikseipp
Copy link
Owner

Good point :-)

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

5 participants