Please also check python scripts that are not named *.py

Bug #970465 reported by Sandro Tosi
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Pyflakes
Fix Committed
Wishlist
Unassigned

Bug Description

Hello,
as reported on Debian at http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=653890:

"""
It would be great if pyflakes could detect files that are python scripts
but are not named *.py. It would have to read the first two bytes of
each file to check for scripts and then read the rest of the line to
determine if it is a python script. It would need to process stuff like:

#!/usr/bin/python
#!/usr/local/bin/python
#!/usr/bin/env python
#!/usr/bin/python2.6
#!/usr/bin/python3.2
"""

Regards,
Sandro

Revision history for this message
Marcin Cieślak (saperski) wrote :

I believe that pyflakes checks any file, regardless whatever the file name is. It even accepts input on stdin. Is this somehow debian specific?

Revision history for this message
Sandro Tosi (morph-debian) wrote : Re: [Bug 970465] Re: Please also check python scripts that are not named *.py

On Mon, Jan 7, 2013 at 12:17 AM, Marcin Cieślak
<email address hidden> wrote:
> I believe that pyflakes checks any file, regardless whatever the file
> name is. It even accepts input on stdin. Is this somehow debian
> specific?

http://bazaar.launchpad.net/~divmod-dev/pyflakes/trunk/view/head:/pyflakes/scripts/pyflakes.py#L91

Revision history for this message
Ian Cordasco (icordasc) wrote :

Personally I'm -1 on this. Theoretically there could be a directory with hundreds of files with only a handful of python files (whether they bear the .py suffix or not). Having to check every file for All variations of `#!/usr/bin/python(version)` seems extraordinary and impractical. One reason not to do this is the following:

Let's assume you have pyflakes installed under 2.6 (or even 2.5) while having files with a header that specifies python 3000 (any version you choose). It will fail upon compilation before it is even capable of doing any checks. That would be useless. On the other hand if you installed under python 3, there are object attributes that are no longer valid. I believe `iteritems` is a popular dictionary method that no longer exists on dictionaries in python 3.

Revision history for this message
Steven Myint (myint) wrote :

Ian, I'm not sure how any of that follows from what Sandro is requesting. I think he is just asking for pyflake's "os.walk()" to look for files other than ones that end with "*.py". So instead of only checking "filename.endswith('.py')", also look for files by reading the first few bytes for the Unix shebang. And then check it against something like the regular expression "^#!.*\bpython[23]?\b\s*$"

Revision history for this message
Phil Frost (bitglue) wrote :

This sounds like a worthwhile feature, as long as it can be demonstrated that it does not significantly impact performance.

Changed in pyflakes:
importance: Undecided → Wishlist
Phil Frost (bitglue)
Changed in pyflakes:
status: New → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.