-
Notifications
You must be signed in to change notification settings - Fork 756
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 issue #643: Optimize noqa() with an lru_cache for Python 3.2+. #644
Conversation
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.
Please rebase this on current master.
pycodestyle.py
Outdated
try: | ||
from functools import lru_cache | ||
except ImportError: | ||
def lru_cache(maxsize=128): # noqa as it's a fake implementation. |
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 versions of Python are we guarding against here? I think the minimum version we support now is 3.3.
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.
According to your tox.ini, it's 2.6. If the minimum supported version is really 3.3 now, it should probably be dropped from tox.ini?
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.
Sorry, I misspoke. The minimum supported Python 3 version is 3.3. I'm not sure if @IanLee1521 wants to continue to support Python 2.6.
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.
As long as tox.ini
tells 2.6 and 2.7, I'll keep this try, it can easily be dropped later with the drop of 2.x support. I bet some other compatibility things will drop too in any way.
pycodestyle.py
Outdated
in inspect.signature(function).parameters.values() | ||
if parameter.kind == parameter.POSITIONAL_OR_KEYWORD] | ||
except ValueError: | ||
"""Catches "No signature found for builtin <built-in method |
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.
We merged the other code that doesn't rely on scanning the definitions in the module to find checks. Is this still necessary now? You'll need to rebase so I think this is probably unnecessary at this point.
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.
It's in fact no longer needed since the merge (kina makes me happy ^^). Rebased on master.
Had to catch a "No signature found for builtin <built-in method search of _sre.SRE_Pattern object at 0x...>" in 3.4: In python3.4 the search was not detected as a function, now that it's wrapped in an lru_cache it is, yet it still has no signature (it has in 3.5+).
Fixes #643 for Python 3.2+.
Had to catch a "No signature found for builtin <built-in method
search of _sre.SRE_Pattern object at 0x...>" in 3.4:
In python3.4 the search was not detected as a function, now that it's
wrapped in an lru_cache it is, yet it still has no signature (it has
in 3.5+).