import os + import os.path both unused generates only a single slightly confusing warning

Bug #1153355 reported by Martin Olsson
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Pyflakes
Fix Released
Wishlist
John Vandenberg

Bug Description

Consider this Python code:

import os
import os.path
import re
re.search("a", "abd")

...for this code pyflakes will say:
$ pyflakes .
./aaa.py:2: 'os' imported but unused

Instead of if the above I would like it to say:
$ pyflakes .
./aaa.py:1: 'os' imported but unused
./aaa.py:2: 'os.path' imported but unused

Revision history for this message
Martin Olsson (mnemo) wrote :

Bug found in 0.5.0-1ubuntu1

Florent (florent.x)
Changed in pyflakes:
importance: Undecided → Wishlist
Revision history for this message
John Vandenberg (jayvdb) wrote :

fwiw, as of v1.2.0, the error message is less confusing as the name in the error message now matches what appears on the line of the source code:

./aaa.py:2: 'os.path' imported but unused

This was done with

https://github.com/pyflakes/pyflakes/commit/aec68a7847d8dbd1371242f42f9302103a68178f

It had a few bugs (lp:1560134 and lp:1578051), which have fixes yet to be released.

It still does not detect that both are unused, which turns out to be a spectacularly difficult problem to solve in pyflakes, but we're getting closer.

Revision history for this message
John Vandenberg (jayvdb) wrote :

Whoops, I set this to fix released, when it isnt. It should go back to New.

Changed in pyflakes:
assignee: nobody → John Vandenberg (jayvdb)
status: New → Fix Released
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.