I've found that we have a lot of Python files in our Puppet repository that are not checked by flake8 because they are not ending with the `.py` extension:
```
$ find . \( -path ./.git -o -path ./.tox \) -prune -o -type f ! -name "*.*" -exec head -n1 '{}' \; | sort | uniq -c | sort -n | grep python
1 #! /usr/bin/env python
1 #!/usr/bin/env /srv/sentry/bin/python
1 #!/usr/bin/env python2
1 #!/usr/bin/env python3
4 #! /usr/bin/python3
5 #! /usr/bin/python
11 #!/usr/bin/python3
32 #!/usr/bin/python
41 #!/usr/bin/env python
TOTAL:
python: 80 files
python3: 16 files
python2: 1 file
```
Of those, 66 are currently not passing Flake8.
Here 2 different proposal on how we could fix this:
# Improve the Jenkins job to search for those (all the files without extension with a python shebang) and dynamically add them to the Flake8 run. Or, if there is a way, have tox call a script that does this.
- PRO: generic fix, can be applied to any repo; doesn't require people to remember to add them manually
- CON: need a cleanup of all the errors before enabling it
# Given the specific nature of the Puppet repo, add the `.py` extension to the file and change the reference in the Puppet classes so that the target file is generated without the extension as it is now but the source is taken from the `.py` one
- PRO: allow to //opt-in// on a per-file basis
- CON: applicable only to the Puppet repo, subject to people not adding other files without extension
When a single project has it's own repo or it's own sub-tox file it could add all the executable in a bin/ directory and explicitely add it to the flake8 parameters.
Alternatively in some coding styles it is suggested to have **all** Python code inside `.py` files and if an executable file is needed without the extension, a symlink or a bash wrapper should be added.
Thoughts?