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

Documentation shows incorrect pre-commit configuration when using pyproject.toml #172

Closed
balazser opened this issue Apr 4, 2023 · 3 comments · Fixed by #171
Closed

Documentation shows incorrect pre-commit configuration when using pyproject.toml #172

balazser opened this issue Apr 4, 2023 · 3 comments · Fixed by #171
Labels
P: docs Problem with docformatter documentation
Milestone

Comments

@balazser
Copy link

balazser commented Apr 4, 2023

I am trying to use the docformatter hook with pre-commit to format my Python code. However, I am encountering an issue where the docformatter hook does not respect the configuration in my pyproject.toml file when run through pre-commit, but it does respect the configuration when run manually with poetry.

Specifically, I have the following configuration for the docformatter hook in my .pre-commit-config.yaml file:

bash

- repo: https://github.com/PyCQA/docformatter
  rev: v1.5.0
  hooks:
    - id: docformatter
      args: ["--in-place", "--config", "./pyproject.toml"]

However, when I run pre-commit run --all-files docformatter, docformatter seems to ignore the configuration in pyproject.toml and uses its default settings instead. On the other hand, when I run poetry run docformatter ., docformatter correctly uses the settings in pyproject.toml.

Can someone explain why this might be happening, and how I can get docformatter to respect my pyproject.toml configuration when run through pre-commit?

Thank you.

@github-actions github-actions bot added the fresh This is a new issue label Apr 4, 2023
@weibullguy weibullguy added P: bug PEP 257 violation or existing functionality that doesn't work as documented C: convention Relates to docstring format convention S: feedback Open but need feedback from OP to proceed with solution and removed fresh This is a new issue P: bug PEP 257 violation or existing functionality that doesn't work as documented C: convention Relates to docstring format convention labels Apr 4, 2023
@weibullguy
Copy link
Member

weibullguy commented Apr 4, 2023

@balazser this is similar to issue #169. In both cases, I see you're using docformatter-1.5.0. Could you try with docformatter-1.6.0 to see if the problem persists? Also, is it ignoring all settings in pyproject.toml or only certain settings similar to #169?

In all of my pre-commits, docformatter reads pyproject.toml, but the only thing I set is:

[tool.docformatter]
wrap-summaries = 88
wrap-descriptions = 88

I also don't quote the args in .pre-commit-config.yaml although it should work either way.

@weibullguy
Copy link
Member

weibullguy commented Apr 4, 2023

Actually, now that I look at my .pre-commit-config.yaml

- repo: https://github.com/PyCQA/docformatter
  rev: v1.6.0
  hooks:
    - id: docformatter
      additional_dependencies: [tomli]
      args: [--in-place, --config, ./pyproject.toml]

you probably need to add the additional_dependencies: [tomli] line to your .pre-commit-config.yaml. If that solves your issue, this is a docformatter documentation issue.

@weibullguy weibullguy added this to the v1.7.0 milestone Apr 4, 2023
@balazser
Copy link
Author

balazser commented Apr 5, 2023

Hi @weibullguy,
I can confirm adding additional_dependencies: [tomli] solved my problem using docformatter-1.5.0. I appreciate your help!
Should we mention it in the doc here? 🤔

@weibullguy weibullguy added P: docs Problem with docformatter documentation and removed S: feedback Open but need feedback from OP to proceed with solution labels Apr 5, 2023
@weibullguy weibullguy changed the title Running pre-commit with docformatter hook does not respect pyproject.toml Documentation shows incorrect pre-commit configuration when using pyproject.toml Apr 5, 2023
@github-actions github-actions bot added the fresh This is a new issue label Apr 5, 2023
@weibullguy weibullguy removed the fresh This is a new issue label Apr 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P: docs Problem with docformatter documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants