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

How to exclude/skip a file (e.g. poetry.lock)? #65

Open
jamesbraza opened this issue Oct 23, 2023 · 2 comments
Open

How to exclude/skip a file (e.g. poetry.lock)? #65

jamesbraza opened this issue Oct 23, 2023 · 2 comments

Comments

@jamesbraza
Copy link

I am using toml-sort==0.23.1 with the below pyproject.toml config:

[tool.tomlsort]
all = true
in_place = true
trailing_comma_inline_array = true

I integrate toml-sort into my pre-commit like so:

  - repo: https://github.com/pappasam/toml-sort
    rev: v0.23.1
    hooks:
      - id: toml-sort-fix

Running identify to see the associations on poetry.lock:

> identify-cli poetry.lock
["file", "non-executable", "text", "toml"]

We can see it's considered TOML, so toml-sort will pick it up. However, poetry.lock is made programmatically, so it should not be touched by toml-sort.

How can one skip a particular file? I don't see anything in toml-sort --help that will exclude or skip files.

Is the only route right now to use an exclude within pre-commit?

@vfazio
Copy link
Contributor

vfazio commented Jul 24, 2024

i think you would use either the files or exclude option within pre-commit

  - repo: https://github.com/pappasam/toml-sort/
    rev: v0.23.1
    hooks:
      - id: toml-sort
        name: Sort pyproject.toml
        entry: toml-sort
        files: pyproject.toml
        args: []
  - repo: https://github.com/pappasam/toml-sort/
    rev: v0.23.1
    hooks:
      - id: toml-sort
        name: Sort pyproject.toml
        entry: toml-sort
        exclude: poetry.lock
        args: []

@jamesbraza
Copy link
Author

Oh thanks for that, yeah that's a fix for pre-commit usage indeed. I think though then it wouldn't apply to users directly invoking toml-sort from the CLI (outside of pre-commit).

Do you know of a way to configure exclusions from within the pyproject.toml config's tool.tomlsort?

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

2 participants