Skip to content

Configure pyproject.toml to have custom 'pyproject' file type#581

Open
mxr wants to merge 1 commit intomainfrom
mxr-patch-1
Open

Configure pyproject.toml to have custom 'pyproject' file type#581
mxr wants to merge 1 commit intomainfrom
mxr-patch-1

Conversation

@mxr
Copy link
Member

@mxr mxr commented Mar 3, 2026

(Sorry not sure what the right terminology is.)

The main reason to do this is because ruff can lint the pyproject.toml file and it uses types_or to match files. If ruff were to match against 'toml' in its types_or it would match too many files. So the idea is to merge this then update ruff's hook definition to

 - id: ruff-check
   name: ruff check
   description: "Run 'ruff check' for extremely fast Python linting"
   entry: ruff check --force-exclude
   language: python
+  types_or: [python, pyi, jupyter, pyproject]
-  types_or: [python, pyi, jupyter]

I got this idea by looking at how jenkinfiles is defined; although it's a groovy file, it has a custom jenkinsfile-specific file type in this extensions file.

@mxr mxr force-pushed the mxr-patch-1 branch 2 times, most recently from a5237c4 to 82bde57 Compare March 3, 2026 13:42
@mxr
Copy link
Member Author

mxr commented Mar 3, 2026

Oops, this should be changing the pyproject.yaml file, not the uvlock file edit: fixed

@mxr mxr closed this Mar 3, 2026
@mxr mxr changed the title Redefine uv.lock have custom 'uvlock' file type Redefine pyproject.toml to have custom 'pyproject' file type Mar 3, 2026
@mxr mxr reopened this Mar 3, 2026
@bn-andrew
Copy link

Thanks Max,

I think that is a very neat solution!

I was going to say on #578 (but I have been locked out of the conversation) that I completely forgot about the ruff-pre-commit existing / having it's own defaults. Makes complete sense now why I was seeing the results I was.

But yes I do think having this as it's own type should allow for much neater configs, both in ruff-pre-commit and even other hooks 👍🏻

Cheers

@mxr mxr changed the title Redefine pyproject.toml to have custom 'pyproject' file type Configure pyproject.toml to have custom 'pyproject' file type Mar 4, 2026
(Sorry not sure what the right terminology is.)

The main reason to do this is because `ruff` can lint the `pyproject.toml` file and it uses `types_or` to match files. If `ruff` were to match against 'toml' in its `types_or` it would match too many files. So the idea is to merge this then update ruff's hook definition to

```diff
 - id: ruff-check
   name: ruff check
   description: "Run 'ruff check' for extremely fast Python linting"
   entry: ruff check --force-exclude
   language: python
+  types_or: [python, pyi, jupyter, pyproject]
-  types_or: [python, pyi, jupyter]
```

I got this idea by looking at how jenkinfiles is defined; although it's a groovy file, it has a custom jenkinsfile-specific file type in this extensions file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants