H501 position incorrect

Bug #1648594 reported by LandonAbney
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
hacking
New
Undecided
Unassigned

Bug Description

The position reported for `H501 Do not use locals() for string formatting` errors seem to only be correct if the line is completely un-indented. If there is any sort of indentation the position reported seems to go up by 2 for every space at the start of the line.

This get's rather broken to the point where in the following (very contrived) code it reports a position of `8:49`, which is past the end of the line.

```
def foo():
    print('H501 %(self)s' % locals())

    def bar():
        print('H501 %(self)s' % locals())

        def foobar():
            print('H501 %(self)s' % locals())

print('H501 %(self)s' % locals())
```

```
> flake8 hacking.py
hacking.py:2:33: H501 Do not use locals() for string formatting
hacking.py:5:41: H501 Do not use locals() for string formatting
hacking.py:8:49: H501 Do not use locals() for string formatting
hacking.py:10:25: H501 Do not use locals() for string formatting
```

Revision history for this message
LandonAbney (landonabney) wrote :

Sorry, should have mentioned that the expected ranges are:
2:29
5:33
8:37
10:25

And that this was last tested with flake8 version:
```
2.5.5 (pep8: 1.5.7, mccabe: 0.2.1, ProxyChecker: 0.0.1, hacking.core: 0.0.1, pyflakes: 0.8.1) CPython 3.5.2 on Windows
```

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.