Repository navigation
(Very) Long lines in exercises #2579
Copy link
Copy link
Closed
Description
I agree that by now PEP8 is dated and modern setups easily and conveniently display more than 79 characters in a line of code. However, I'm not aware of any widely used conventions or IDEs that go beyond 120 characters by default (most likely for the sake of readability).
In that regard, there is a handful of violators within exercises, namely - presented as LONGEST_LINE_LENGTH, FILENAME, LONGEST_LINE_CONTENTS - the following:
1734 exercises/concept/cater-waiter/sets_test_data.py {'dried fenugreek leaves', 'apple cider vinegar', 'cinnamon sticks', 'roasted chicken', 'cumin', 'mangoes', 'heavy cream', 'micro cilantro', 'white vinegar', 'red chili powder', 'cinnamon powder', 'mustard seeds', 'red wine vinegar', 'mirin', 'cinnamon', 'green chili', 'avocado oil', 'curry leaves', 'star anise', 'dijon mustard', 'crunchy peanut butter', 'grilled king fish', 'chicken', 'fresh basil', 'cashew nuts', 'pink peppercorns', 'pork belly', 'spinach', 'watercress', 'whole small crimini mushrooms', 'coconut flour', 'fresh ginger', 'fennel bulb', 'harissa', 'tahini', 'mozzarella cheese', 'scallions', 'sriacha', 'fresh parsley', 'thyme', 'light soy sauce', 'cream cheese', 'hing', 'coriander seeds', 'sour cream', 'turmeric powder', 'castelfranco radicchio', 'parmesan', 'toasted buckwheat', 'coriander powder', 'dark soy sauce', 'granny smith apples', 'parsley', 'shrimp', 'garlic paste', 'roasted peanuts', 'turmeric', 'carrot', 'garam masala', 'clove powder', 'cucumbers', 'tomato paste', 'almond meal', 'dutch carrot', 'brussel sprouts', 'red and green thai chili', 'shallots', 'nigella seeds', 'cardamom powder', 'watermelon radishes', 'flaxmeal', 'cilantro', 'fennel seeds', 'chipotle chili', 'ghee', 'parmesan cheese', 'radishes', 'pork chops', 'cilantro leaves', 'fresh greek yogurt', 'cardamom', 'mango powder', 'onion', 'oregano', 'fresh red chili', 'pecans', 'salmon fillets', 'basil', 'green cabbage', 'cumin powder', 'almond flour', 'lemon', 'boned chicken', 'oyster sauce', 'soy sauce', 'little gem lettuce heads', 'peanut oil', 'peanuts', 'caster sugar', 'salmon steaks', 'ginger garlic paste', 'green onions', 'vinegar', 'cloves', 'kecap manis', 'avocado', 'chili flakes', 'red chili flakes', 'tomatoes'},
1019 exercises/practice/largest-series-product/largest_series_product_test.py "7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450",
434 exercises/practice/house/house_test.py "This is the horse and the hound and the horn that belonged to the farmer sowing his corn that kept the rooster that crowed in the morn that woke the priest all shaven and shorn that married the man all tattered and torn that kissed the maiden all forlorn that milked the cow with the crumpled horn that tossed the dog that worried the cat that killed the rat that ate the malt that lay in the house that Jack built.",
138 exercises/practice/say/say_test.py "nine hundred eighty-seven billion six hundred fifty-four million three hundred twenty-one thousand one hundred twenty-three",
129 exercises/concept/making-the-grade/loops_test.py msg=f'Expected: {result} but the grade thresholds for a high score of {highest} are incorrect.')
126 exercises/concept/little-sisters-vocab/strings_test.py result_data = 'en :: encircle :: enfold :: enclose :: enjoy :: enlighten :: entangle :: enable :: encode :: enculture'
122 exercises/concept/restaurant-rozalynn/none_test.py accommodate_waiting_guests(starting_reservations, ["Mort", "Suze", "Phillip", "Tony"]), starting_reservations,
121 exercises/practice/bowling/bowling_test.py def test_the_second_bonus_rolls_after_a_strike_in_the_last_frame_cannot_be_a_strike_if_the_first_one_is_not_a_strike(
121 exercises/concept/cater-waiter/sets_categories_data.py 'toasted bread', 'parmesan', 'beef', 'tofu', 'flour', 'tomatoes', 'red onion', 'slivered almonds',
obtained by running
find exercises -type f -name "*.py" | while read file; do
cat "$file" | awk -v f="$file" 'length > 120 {print length, f, $0}' | sort -n | tail -1
done | sort -nrShould something be done about those? Happy to contribute.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
BethanyG commentedon Sep 14, 2021
@pranasziaukas -- Thank you for running this, and for logging an issue about results! 😄
Agree that there are some exercises that are egregious. A few thoughts:
setstest files (sets_categories_data.pyandsets_test_data.py) myself, I formatted them that way for ease of scanning and ease of finding things. Since they are (mostly) used to store and load data for that exercise and not intended to have active maintenance or lengthly reading, I don't think line length should be a consideration there.little sisters vocabularyI will have to take a look again, but I remember thinking I wanted to leave the lines alone, because they flowed/read less confusingly. That being said, it is a test file, so we may want to move those to an external "test data" fixture or file. But that would be later.practiceexercises are auto-generated. If a file is auto-generated, I am not going to be inclined to prioritize changing the template for line length at this time. We'll have to research which are and which are not auto-generated. But again, after the track settles a bit.Making the grade. I struggle with the status/failure messages in test files. The setup is a bit awkward. It would be nice to be able to be shorter and more programmatic about them (or have a fixture or file, etc.). I'll think about it a bit. This is another thing that has tooling involvement, since the error messages are packaged into theresults.jsonand delivered to the site.BethanyG commentedon Sep 14, 2021
Happy to have an ongoing discussion in this issue, but I am going to flag this as stats "on hold", simply because we need to focus on higher-priority issues such as adding new concepts and exercises, updated tooling, and fixing obvious errors and typos in existing exercises.
pranasziaukas commentedon Sep 14, 2021
Thanks for the thoughtful response. Given the circumstances, makes sense to not prioritize it at this point in time.
BethanyG commentedon Oct 18, 2021
Looping back a bit with some comments.
Having decided on tooling (pylint, flake8) and written a contributors file, I have gone back and linted the
Concept Exercisedirectory. There are now a bunch of PRs for correcting msc. linting errors, and the majority of problems, including line length should now be resolved.The one exception is
making the grade, which I left alone because there is work pending on it.So that leaves
Practice Exercises, which I am going to lint, but may not submit changes for at this time. Depends on if they are auto generated, and what the violation is.BethanyG commentedon Nov 29, 2021
Now that @J08K has finished linting (THANK YOU). I think we can safely close this issue.