alexcouper / captainhook

Git hook scripts
BSD 3-Clause "New" or "Revised" License
54 stars 14 forks source link

Python files without extension (e.g. scripts) aren't checked #25

Closed OddBloke closed 10 years ago

OddBloke commented 10 years ago

We have a couple of flake8 errors in the captainhook script which we haven't noticed because we only look at files matching "*.py".

file works out that it's Python, so there should be something relatively easy we can do:

$ file scripts/captainhook
scripts/captainhook: Python script, ASCII text executable
alexcouper commented 10 years ago

Yep, this would be great!

OddBloke commented 10 years ago

The best way to do it would probably be to use python-magic (https://github.com/ahupp/python-magic) to look at all of the files being staged. However, this would introduce an external dependency in to the hook file, which we currently can't handle.

So we could either use the file command directly using bash(), or we could try and think of a way of having access to Python dependencies from within the installed stuff (which would also be useful for flake8).

alexcouper commented 10 years ago

I prefer not to have dependencies if possible. Obviously flake8 is one already, but what we're talking about here would be used by python3 and pdb checkers too, so I'd lean towards the file approach I guess...

OddBloke commented 10 years ago

This is also going to be a problem with the isort checker, once I write it.

I'll have a play around at some point to see if I can find a decent way of having access to dependencies.

In the mean time, though, fixing this by calling file directly is (I agree) probably the thing to do.

alexcouper commented 10 years ago

I believe this is resolved as of #27