Skip to content
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

Merged
merged 1 commit into from
Jun 4, 2017
Merged

Fix issue #643: Optimize noqa() with an lru_cache for Python 3.2+. #644

merged 1 commit into from
Jun 4, 2017

Conversation

JulienPalard
Copy link
Contributor

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+).

Copy link
Member

@sigmavirus24 sigmavirus24 left a 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.
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

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
Copy link
Member

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.

Copy link
Contributor Author

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+).
@sigmavirus24 sigmavirus24 merged commit 454e035 into PyCQA:master Jun 4, 2017
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.

2 participants