Skip to content

Add pyproject.toml support for config (Issue #10) #77

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

Merged
merged 1 commit into from
Jul 29, 2022

Conversation

weibullguy
Copy link
Member

@weibullguy weibullguy commented Aug 19, 2021

I submit for your consideration a potential solution to issue #10 .

This adds two functions:

  • One to find the config file specified with the new --config option and compare it against a list of supported config files (currently only pyproject.toml).
  • A second function to read the contents of the config file into a dict which is returned to _main().

The dict is used to set default values in the add_argument() methods, thus ensuring command line options take precedence. Adding additional config files (e.g., setup.cfg, tox.ini) should be reasonably trivial with these functions.

Four tests have been added to the test suite to test these two functions and a section added to the README to explain the use of pyproject.toml. All tests pass as well as all static checks. I've been successfully using my fork for my use cases; command line, key-mapped in IDE, pre-commit and GH actions.

Closes #10

@dyve
Copy link

dyve commented Oct 14, 2021

👍 This would be most welcome.

@ghisvail
Copy link

Indeed. Most formatter and linters now support the [tool.X] section of pyproject.toml which avoids config proliferation in code trees. Could you please merge this and consider a new release 🙏 ?

@jorgepiloto
Copy link

I would be super cool to have pyproject.toml support for configuring docformatter. Which is the current status of this, @myint?

@mdczaplicki
Copy link

This project is abandonware, right?

@dyve
Copy link

dyve commented May 11, 2022

@mdczaplicki I hope not, maybe @myint can give some info?

@myint
Copy link
Member

myint commented May 13, 2022

@dyve Would you be interested in becoming a maintainer?

@weibullguy
Copy link
Member Author

weibullguy commented Jul 16, 2022

@myint I'd be open to lending a hand to help get things moving.

@myint
Copy link
Member

myint commented Jul 16, 2022

@weibullguy Welcome aboard! Thanks for sticking to this PR for a year. 🙈

@fmigneault
Copy link

@weibullguy
Would it possible to modify the explicit .toml extension check in the function reading the config file? It looks to me like the expected tool.docformatter section would work also inside setup.cfg and .ini config files.

@weibullguy
Copy link
Member Author

@fmigneault
Since this request was made in 2016, it looked like the consensus was moving to pyproject.toml support. Plus that's what I use in other projects (docformatter does now too!), so I may be biased. At the moment, I want to focus on closing out the issues and merging PRs that have been around for these many years, then I plan to do a top-to-bottom refactoring.

I opened issue #92 to track this. As far as I know, the toml library will only read *.toml files. So, the function would need more work than removing the extension check. I'm thinking all the configuration file stuff will end up in a class, but I'll figure that out when I refactor.

@weibullguy
Copy link
Member Author

weibullguy commented Aug 3, 2022

To everyone who's been waiting for some sort of config file support, I don't have the access rights to push tags or upload new releases to pypi. For now for pyproject.toml support, you'll need to:

git clone https://github.com/PyCQA/docformatter.git
cd docformatter
pip install .[tomli] or pip install --user .[tomli]

For adding git dependencies, see:

pyproject.toml
setup.py

@dyve
Copy link

dyve commented Aug 3, 2022

@weibullguy Thanks! I hope this gets to PyPI and that the projects remains alive!

@dyve Would you be interested in becoming a maintainer?

@myint I don't have the time to take on another maintainer role, but I'd say @weibullguy is stepping up. Perhaps he can also get PyPI rights?

@myint
Copy link
Member

myint commented Aug 3, 2022

Done!

@weibullguy weibullguy added P: enhancement Feature that is outside the scope of PEP 257 C: stakeholder Relates to docformatter stakeholder requested behavior labels Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: stakeholder Relates to docformatter stakeholder requested behavior P: enhancement Feature that is outside the scope of PEP 257
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Global config with "docformatterrc"
7 participants