I was also unable to reproduce your PEP8 warning with the code you showed above. Perhaps you could put your exact code in a pastebin?
The example test cases for PEP8 (if you use the --show-pep8 option) are as follows:
Avoid extraneous whitespace in the following situations:
- Immediately inside parentheses, brackets or braces.
- Immediately before a comma, semicolon, or colon.
Okay: spam(ham[1], {eggs: 2})
E201: spam( ham[1], {eggs: 2})
E201: spam(ham[ 1], {eggs: 2})
E201: spam(ham[1], { eggs: 2})
E202: spam(ham[1], {eggs: 2} )
E202: spam(ham[1 ], {eggs: 2})
E202: spam(ham[1], {eggs: 2 })
E203: if x == 4: print x, y; x, y = y , x
E203: if x == 4: print x, y ; x, y = y, x
E203: if x == 4 : print x, y; x, y = y, x
Also, I haven't actually used Textmate, but if you're doing on the fly checking similar to emacs' flymake mode, then it could also be that pep8 is getting called on an old version of the file, and the issue may go away when you save the file. We may need more information to debug further.
As for the formatting of the list comprehension itself, you may want to take a look at this other SO question as well as the take from the Google style guide. I personally have no problem with the way you did it. I suppose you could also do something like
def _question_tuple(q):
return (
q,
q.vote_set.filter(choice__exact='Y'),
q.vote_set.filter(choice__exact='N'),
request.session.get(str(q.id))
)
question_tups = [_question_tuple(q) for q in questions]
but it's really about what will be the most readable/maintainable, and that's up to your own judgment.