Skip to content

Allow pyproject.toml to define pre-commit config #1165

Closed

Description

@a-recknagel

pyproject.toml allows development tools to store their configs in a section called after their pypi name. Some projects like black have started adopting it, and it would be nice if other tools started to support it as well to reduce the amount of config files that lie around at the project root.

I realize that that porting pre-commit's config is not trivial, so it might not be worth the effort. But since I couldn't find an existing issue I thought I'd ask.

Activity

  1. asottile commented on Oct 9, 2019

    @asottile
    Member

    no sorry, I have no interest in pyproject.toml and this

  2. ierezell commented on Jun 16, 2021

    @ierezell

    Sorry to bump this closed issue but have your mind changed in two years ?

    I love pre-commit and it's really useful.
    With the new pep rules coming and all the tools adopting the format for the configuration it's really nice to have all the config in one place.

    Thanks for your work
    Have a great day

  3. locked as resolved and limited conversation to collaborators on Jun 16, 2021
  4. asottile commented on Jun 16, 2021

    @asottile
    Member

    Sorry to bump this closed issue

    yeah don't do that -- it's closed for a reason

  5. asottile commented on Jun 16, 2021

    @asottile
    Member

    you also don't actually want this, toml is really bad at representing nested structures:

    ["tool.pre-commit"]
    [["tool.pre-commit".repos]]
    repo = "https://github.com/pre-commit/pre-commit-hooks"
    rev = "v4.0.1"
    [["tool.pre-commit".repos.hooks]]
    id = "trailing-whitespace"
    
    [["tool.pre-commit".repos.hooks]]
    id = "end-of-file-fixer"
    
    [["tool.pre-commit".repos.hooks]]
    id = "check-docstring-first"
    
    [["tool.pre-commit".repos.hooks]]
    id = "check-json"
    
    [["tool.pre-commit".repos.hooks]]
    id = "check-yaml"
    
    [["tool.pre-commit".repos.hooks]]
    id = "debug-statements"
    
    [["tool.pre-commit".repos.hooks]]
    id = "name-tests-test"
    
    [["tool.pre-commit".repos.hooks]]
    id = "requirements-txt-fixer"
    
    [["tool.pre-commit".repos.hooks]]
    id = "double-quote-string-fixer"
    
    
    [["tool.pre-commit".repos]]
    repo = "https://github.com/PyCQA/flake8"
    rev = "3.9.2"
    [["tool.pre-commit".repos.hooks]]
    id = "flake8"
    additional_dependencies = [ "flake8-typing-imports==1.10.0",]
    
    
    [["tool.pre-commit".repos]]
    repo = "https://github.com/pre-commit/mirrors-autopep8"
    rev = "v1.5.7"
    [["tool.pre-commit".repos.hooks]]
    id = "autopep8"
    
    
    [["tool.pre-commit".repos]]
    repo = "https://github.com/pre-commit/pre-commit"
    rev = "v2.13.0"
    [["tool.pre-commit".repos.hooks]]
    id = "validate_manifest"
    
    
    [["tool.pre-commit".repos]]
    repo = "https://github.com/asottile/pyupgrade"
    rev = "v2.16.0"
    [["tool.pre-commit".repos.hooks]]
    id = "pyupgrade"
    args = [ "--py36-plus",]
    
    
    [["tool.pre-commit".repos]]
    repo = "https://github.com/asottile/reorder_python_imports"
    rev = "v2.5.0"
    [["tool.pre-commit".repos.hooks]]
    id = "reorder-python-imports"
    args = [ "--py3-plus",]
    
    
    [["tool.pre-commit".repos]]
    repo = "https://github.com/asottile/add-trailing-comma"
    rev = "v2.1.0"
    [["tool.pre-commit".repos.hooks]]
    id = "add-trailing-comma"
    args = [ "--py36-plus",]
    
    
    [["tool.pre-commit".repos]]
    repo = "https://github.com/asottile/setup-cfg-fmt"
    rev = "v1.17.0"
    [["tool.pre-commit".repos.hooks]]
    id = "setup-cfg-fmt"
    
    
    [["tool.pre-commit".repos]]
    repo = "https://github.com/pre-commit/mirrors-mypy"
    rev = "v0.812"
    [["tool.pre-commit".repos.hooks]]
    id = "mypy"
    exclude = "^testing/resources/"
    
    
    [["tool.pre-commit".repos]]
    repo = "meta"
    [["tool.pre-commit".repos.hooks]]
    id = "check-hooks-apply"
    
    [["tool.pre-commit".repos.hooks]]
    id = "check-useless-excludes"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions