pre-commit / identify

File identification library for Python
MIT License
246 stars 140 forks source link

salt sls files with python shebangs are not properly recognized #61

Open raddessi opened 5 years ago

raddessi commented 5 years ago

Some salt sls files are written in python directly, I've added those interpreters in a PR here https://github.com/chriskuehl/identify/pull/60 as well as disabled the executable checks since these files are not required to be and also disabled the optimization for skipping peeking at the file contents if we recognize the extension.. I do see how this a nice speedup though.. maybe the extensions.EXTENSIONS dict should be changed from:

EXTENSIONS = {
...
    'sh': {'text', 'shell'},
    'sls': {'text', 'salt'},
    'so': {'binary'},
...
}

to something like:

EXTENSIONS = {
...
    'sh': {
        'tags': {'text', 'shell'},
        },
    'sls': {
        'tags': {'text', 'salt'},
        'always-peek': True,
    },
    'so': {
        'tags': {'binary'},
    },
...
}

By changing each value to its own dict which could have an optional key always-peek(?) so then you could .get('always-peek', False) to check if the file should be inspected?

raddessi commented 5 years ago

Hmm, let me fix those failing unit tests first..

raddessi commented 5 years ago

Should be happy now :)