pyflakes native support for Python 3

Bug #989203 reported by Barry Warsaw
82
This bug affects 16 people
Affects Status Importance Assigned to Milestone
Pyflakes
Fix Released
Medium
Florent

Bug Description

Let's say you have this file:

#! /usr/bin/python
from __future__ import print_function
import sys
print('test', file=sys.stderr)

then pyflakes correct recognizes the print function and is happy. However, let's say you change the first line to

#!/usr/bin/python3

and remove the future import. Then pyflakes isn't so happy about the print() function.

No doubt it's a considerable amount of work to support Python 3 directly, but at least with this bug we can track that effort.

Related branches

Revision history for this message
Florent (florent.x) wrote :

This branch brings Python 3 support https://github.com/florentx/pyflakes

It is based on version 0.5 from lp:divmod.org

Revision history for this message
Florent (florent.x) wrote :

Planned after the switch to unittest2 for the tests (https://bugs.launchpad.net/pyflakes/+bug/1097061).

The only limitation will be that you need to run with Python2 to check Python2 code, and you'll need to run with Python3 to check Python3 code.

Changed in pyflakes:
status: New → Confirmed
Florent (florent.x)
Changed in pyflakes:
importance: Undecided → Medium
assignee: nobody → Florent (florent.x)
Florent (florent.x)
Changed in pyflakes:
status: Confirmed → In Progress
Florent (florent.x)
Changed in pyflakes:
status: In Progress → Fix Committed
Revision history for this message
James (bistromathic1) wrote :

Maybe you are aware of this (and thanks for adding python 3 support!), but there are some bits of new syntax that don't seem to be covered by this fix. The following code causes pyflakes to complain that ABCMeta is unused:

from abc import ABCMeta

class A(metaclass=ABCMeta): # new metaclass syntax
    pass

def f(a: ABCMeta): # annotations
    pass

def g(a, *args, b=ABCMeta): # defaults for keyword-only arguments
    pass

Revision history for this message
Florent (florent.x) wrote :

Thank you for reporting it

I will investigate these cases.

Changed in pyflakes:
status: Fix Committed → In Progress
Revision history for this message
Florent (florent.x) wrote :
Changed in pyflakes:
status: In Progress → Fix Committed
Revision history for this message
Florent (florent.x) wrote :
Florent (florent.x)
Changed in pyflakes:
status: Fix Committed → Fix Released
Florent (florent.x)
Changed in pyflakes:
milestone: none → 0.6.1
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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