Are one-line lambda functions bad practice per PEP8?

Viewed 141

Recently I've found a VSCode extension that can 'beautify' code according to PEP8. I noticed a few strange changes that I would like to confirm are PEP8 and not a fault of the extension:

  • All lambda functions were converted to one-line functions with return statements on the same line: def(...): return .... As I understand it, return and else statements should be placed on their own line.
  • All in-line comments got moved to the line above the code which makes it much more cluttered.
  • 2 spaces were inserted above each function; creating a 2-line gap between the comment block and function heading.
  • Certain lines of code not yet reaching the 80 char PEP8 limit were forced to a new line. For example: (age = dict['base_age'] + years - 1) got cut off after the dict call.
0 Answers
Related