Skip to content

Maximum Line Length #434

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
rootulp opened this issue Mar 19, 2017 · 7 comments
Closed

Maximum Line Length #434

rootulp opened this issue Mar 19, 2017 · 7 comments

Comments

@rootulp
Copy link
Contributor

rootulp commented Mar 19, 2017

The Code Style section states:

The Python code in this repo is meant to largely obey the PEP8 style guide.

PEP8 states:

Limit all lines to a maximum of 79 characters.

However we encourage developers to check code style with:

flake8 [your-code-here.py] --max-line-length=99 --select=E,W

Why do we use a max-line-length of 99 characters instead of 79 characters?

@behrtam
Copy link
Contributor

behrtam commented Mar 19, 2017

#299 You seem to like this number 😉

@rootulp
Copy link
Contributor Author

rootulp commented Mar 19, 2017

I like this number because it is prescribed by the style guide we conform to. I don't see a reason to override this standard.

@behrtam
Copy link
Contributor

behrtam commented Mar 20, 2017

We only "largely obey the PEP8" ... and I just see no reason to work with a hard limit of 80 characters only because IBM choose that number for their punchcards. The goal should be to avoid long lines but not at all costs.

@rootulp
Copy link
Contributor Author

rootulp commented Mar 20, 2017

I didn't know the IBM punchcard was the origin for the 80 character limit - thanks for sharing!

This StackOverflow answer resonates with me:

To view multiple source windows side-by-side or using a side-by-side diff viewer.

Also the Google Style Guide also uses an 80 character limit.

@behrtam
Copy link
Contributor

behrtam commented Mar 20, 2017

Most of the arguments for the limit of 80 are totally esoteric ... but just working with flake8 default settings would make things a little bit easier for new people. But to get to that point we would need to uglify some parts of our code like grep_test.py only because of one or two characters over the hard limit:

Note: I generated a preview #438

    def test_multiple_files_several_matches_print_line_numbers_flag(self):
        self.assertMultiLineEqual(
            grep("that", ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"], "-n"),
            ("midsummer-night.txt:5:But I beseech your grace that I may know\n"
             "midsummer-night.txt:6:The worst that may befall me in this case,\n"
             "paradise-lost.txt:2:Of that Forbidden Tree, whose mortal tast\n"
             "paradise-lost.txt:6:Sing Heav'nly Muse, that on the secret top\n")
        )

    def test_multiple_files_several_matches_case_insensitive_flag(self):
        self.assertMultiLineEqual(
            grep("TO", ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"], "-i"),
            ("iliad.txt:Caused to Achaia's host, sent many a soul\n"
             "iliad.txt:Illustrious into Ades premature,\n"
             "iliad.txt:And Heroes gave (so stood the will of Jove)\n"
             "iliad.txt:To dogs and to all ravening fowls a prey,\n"
             "midsummer-night.txt:I do entreat your grace to pardon me.\n"
             "midsummer-night.txt:In such a presence here to plead my thoughts;\n"
             "midsummer-night.txt:If I refuse to wed Demetrius.\n"
             "paradise-lost.txt:Brought Death into the World, and all our woe,\n"
             "paradise-lost.txt:Restore us, and regain the blissful Seat,\n"
             "paradise-lost.txt:Sing Heav'nly Muse, that on the secret top\n")
        )
    def test_multiple_files_several_matches_print_line_numbers_flag(self):
        self.assertMultiLineEqual(
            grep("that",
                 ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"],
                 "-n"),
            ("midsummer-night.txt:5:But I beseech your grace that I may know\n"
             "midsummer-night.txt:6:The worst that may befall me in this case,"
             "\nparadise-lost.txt:2:Of that Forbidden Tree, whose mortal tast"
             "\nparadise-lost.txt:6:Sing Heav'nly Muse, that on the secret top"
             "\n"
             ))

    def test_multiple_files_several_matches_case_insensitive_flag(self):
        self.assertMultiLineEqual(
            grep("TO",
                 ["iliad.txt", "midsummer-night.txt", "paradise-lost.txt"],
                 "-i"),
            ("iliad.txt:Caused to Achaia's host, sent many a soul\n"
             "iliad.txt:Illustrious into Ades premature,\n"
             "iliad.txt:And Heroes gave (so stood the will of Jove)\n"
             "iliad.txt:To dogs and to all ravening fowls a prey,\n"
             "midsummer-night.txt:I do entreat your grace to pardon me.\n"
             "midsummer-night.txt:In such a presence here to plead my thoughts"
             ";\nmidsummer-night.txt:If I refuse to wed Demetrius.\n"
             "paradise-lost.txt:Brought Death into the World, and all our woe,"
             "\nparadise-lost.txt:Restore us, and regain the blissful Seat,\n"
             "paradise-lost.txt:Sing Heav'nly Muse, that on the secret top\n"))

That's why I like a soft limit instead. Always try to get below 79 and only in some rare cases cross it if it helps readability but never over 99.

behrtam added a commit to behrtam/python that referenced this issue Mar 20, 2017
behrtam added a commit to behrtam/python that referenced this issue Mar 20, 2017
@behrtam
Copy link
Contributor

behrtam commented Mar 20, 2017

@rootulp I really like your input and this track could use more people like you. So let's just merge #438 and get real things done instead of arguing about tabs vs spaces or 79 vs 99 max line length.

@rootulp
Copy link
Contributor Author

rootulp commented Mar 20, 2017

but just working with flake8 default settings would make things a little bit easier for new people

Awesome! I feel strongly that this is the case.

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

2 participants