Skip to content

Conversation

@cdce8p
Copy link
Member

@cdce8p cdce8p commented May 2, 2021

Fix false-positive E211 whitespace before '(' for match and case, Python 3.10

pycodestyle.py Outdated
# Allow "return (a.foo for a in range(5))"
not keyword.iskeyword(prev_text) and
# 'match' and 'case' are only soft keywords
prev_text not in ('match', 'case')
Copy link
Member

@asottile asottile May 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps sys.version_info >= (3, 9) and not keyword.issoftkeyword(prev_text) (err, might need some boolean flipping, but you get the idea)

https://docs.python.org/3.10/library/keyword.html#keyword.issoftkeyword

#: Okay
case (1, 2):
pass
#: Okay
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the #: is supposed to split separate cases -- you shouldn't need anything except the first comment (also please include the var1, var2 in the example)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌🏻 Didn't know that. Is there a way to run the test case only for Python 3.10+? Especially with the first change you suggested, the tests will fail without it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the file naming is supposed to handle that, but it looks like this needs to have a + added to the second digit group here:

ver_match = re.search(r'python(\d)(\d)?\.py$', filename)

Copy link
Member

@asottile asottile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cdce8p
Copy link
Member Author

cdce8p commented May 2, 2021

Should I add 3.10 to Github CI action as well?

@asottile
Copy link
Member

asottile commented May 2, 2021

Should I add 3.10 to Github CI action as well?

yeah that would be good! thanks

@cdce8p
Copy link
Member Author

cdce8p commented May 2, 2021

Should I add 3.10 to Github CI action as well?

yeah that would be good! thanks

Done. All tests passed 🚀

@asottile asottile merged commit 61138ca into PyCQA:master May 2, 2021
@cdce8p cdce8p deleted the whitespace-match-false-positive branch May 2, 2021 19:56
@east825
Copy link

east825 commented Jul 9, 2021

Hi there! @asottile Do you plan to make a release with bug fixes for pattern matching support (this one in particular) before Python 3.10 comes out?

@asottile
Copy link
Member

asottile commented Jul 9, 2021

please don't ask for releases, they will happen when they happen

these are not bugfixes, this is a feature and it is not complete (there are still issues with match)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants