Skip to content

Need a solution for long lines in Python 2 #534

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
stephenfin opened this issue Jan 26, 2018 · 2 comments
Closed

Need a solution for long lines in Python 2 #534

stephenfin opened this issue Jan 26, 2018 · 2 comments

Comments

@stephenfin
Copy link

This is a continuation of #186 and, like that change, has also been reported to mypy. I propose reading onto the following line for comments:

import collections
from typing import DefaultDict, List


def test(pools):
    really_long_attribute = collections.defaultdict(list)
    # type: DefaultDict[str, List[str]]
    for pool in pools:
        pass  # meaningful stuff in here

This seems clear enough and should require minimal changes to the parser. I'm happy to propose an amendment to the PEP, but I'd like to get some input first.

@emmatyping
Copy link
Member

I'm -1 on this. I don't think it is needed and is not clear. People will get confused and sometimes think that types come on the line before the definition. If you find your lines are getting too long due to types, you should use an alias. This is much more logical and unambiguous. A line is a definite encapsulation of an idea, and I don't think breaking that is a good idea.

@gvanrossum
Copy link
Member

gvanrossum commented Jan 26, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants