Skip to content

Commit

Permalink
Combine rstrip calls in trailing_whitespace check
Browse files Browse the repository at this point in the history
This provides a small speed-up on large codebases.
  • Loading branch information
correctmost committed Aug 9, 2024
1 parent 3d5962b commit 035b52f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pycodestyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,11 @@ def trailing_whitespace(physical_line):
W291: spam(1) \n#
W293: class Foo(object):\n \n bang = 12
"""
physical_line = physical_line.rstrip('\n') # chr(10), newline
physical_line = physical_line.rstrip('\r') # chr(13), carriage return
physical_line = physical_line.rstrip('\x0c') # chr(12), form feed, ^L
# Strip these trailing characters:
# - chr(10), newline
# - chr(13), carriage return
# - chr(12), form feed, ^L
physical_line = physical_line.rstrip('\n\r\x0c')
stripped = physical_line.rstrip(' \t\v')
if physical_line != stripped:
if stripped:
Expand Down

0 comments on commit 035b52f

Please sign in to comment.