From 035b52f15eb6ecca44460567d1961ab47a758c12 Mon Sep 17 00:00:00 2001 From: correctmost <134317971+correctmost@users.noreply.github.com> Date: Fri, 9 Aug 2024 04:30:09 -0400 Subject: [PATCH] Combine rstrip calls in trailing_whitespace check This provides a small speed-up on large codebases. --- pycodestyle.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pycodestyle.py b/pycodestyle.py index c4c8dbaa..ec07aaac 100755 --- a/pycodestyle.py +++ b/pycodestyle.py @@ -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: