-
Notifications
You must be signed in to change notification settings - Fork 751
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
Fix regression in E302 detection #618
Conversation
This was similar to an issue we had with E306 in which we were only checking that a line started with "def" or "class" which catches global vars like "defaults" or "classification". Closes PyCQAgh-617
@@ -122,7 +122,7 @@ | |||
LAMBDA_REGEX = re.compile(r'\blambda\b') | |||
HUNK_REGEX = re.compile(r'^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@.*$') | |||
STARTSWITH_DEF_REGEX = re.compile(r'^(async\s+def|def)') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about this one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not all regular expressions named similarly need to be touched all at once. This one is actually fine as is.
@@ -122,7 +122,7 @@ | |||
LAMBDA_REGEX = re.compile(r'\blambda\b') | |||
HUNK_REGEX = re.compile(r'^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@.*$') | |||
STARTSWITH_DEF_REGEX = re.compile(r'^(async\s+def|def)') | |||
STARTSWITH_TOP_LEVEL_REGEX = re.compile(r'^(async\s+def|def|class|@)') | |||
STARTSWITH_TOP_LEVEL_REGEX = re.compile(r'^(async\s+def |def |class |@)') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use "\s" to also detect tabs!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you exclaiming this?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea! Updated!
This was similar to an issue we had with E306 in which we were only
checking that a line started with "def" or "class" which catches global
vars like "defaults" or "classification".
Closes gh-617