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

Add matlab extension #515

Closed
wants to merge 1 commit into from
Closed

Conversation

da-phil
Copy link

@da-phil da-phil commented Mar 25, 2025

I'm using a code-base with matlab *.m files together with pre-commit, identifying matlab files would be quite helpful ;)

@asottile
Copy link
Member

extensions must be unambiguous

@asottile asottile closed this Mar 25, 2025
@da-phil
Copy link
Author

da-phil commented Mar 25, 2025

extensions must be unambiguous

I don't understand. The extension dict is full of multiple associations, some extensions even have 4 associations. I thought this was the whole point of this dict, to create a mapping from a file extension to a programming language or tool. And because extensions can be used by different tools (e.g. .sh can be used by all shells) multiple mappings for the same extensions are to be expected.

@asottile
Copy link
Member

.m is not unambiguously matlab -- that extension is used by many other things and therefore we cannot accept it into the extensions list

there may be things in the list that are ambiguous -- unfortunately mistakes were made in the last decade of this existing and we're trying to not do that moving forward

@da-phil
Copy link
Author

da-phil commented Mar 25, 2025

In this example this would be only a problem if pre-commit would be used in a code-base were both objective-c and matlab files are present. A files regex could be used to disambiguate by path (assuming that matlab and objective-c files are not mixed within the same folders), but then types can be still used for the respective hooks if one wouldn't want to have the file extension part of the files regex.
I mean, it's not a big deal to just deal with it in the files regex, but I really like the readability of something like types: [matlab] or types: [objective-c] and keeping the files regex as simple as possible.

I don't think its a fatal design flaw if types: [matlab] and types: [objective-c] lead to the same filtering behavior for a hook. That's just a mirror of the reality of having the same extension for different interpreters and tools.

Having said that, do you think it would be possible to disambiguate further by adding some content heuristics, similarly to the shebang detection?

@asottile
Copy link
Member

look. I don't have time to debate you. I am telling you how it is.

@pre-commit pre-commit locked as off-topic and limited conversation to collaborators Mar 25, 2025
@da-phil da-phil deleted the add_matlab_extension branch March 26, 2025 22:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants