-
Notifications
You must be signed in to change notification settings - Fork 180
ReturnWithArgsInsideGenerator was removed from API in 2.5.0 - how to update code? #733
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
Comments
yes, it's fine because pyflakes no longer supports python 2 |
Hey @asottile , thanks for the feedback. Would you mind answering my question?
I'm receiving the above error message in Python 3.9. Thanks! Best, |
I'm not sure what your question is, or perhaps it's obvious to me that if something is accessing something that doesn't exist it needs to stop doing that -- could you clarify what you're confused about? |
I'm wondering how I can update that code, which worked with pyflakes 2.4.0 to make it work with pyflakes 2.5.0. Is there a transition guide document somewhere that helps with those things?
The error happens in line 185, becaue this doesn't exist anymore. Is there a replacement? Thanks! |
@haesleinhuepf Anthony has clearly stated it doesn't exist and was removed with python 2 support. The error it represents is no longer an error in Python 3 thus it was removed. Is that clearer? |
Ah, so you're saying I can comment out that line to make it work again. Thanks for your support! |
I just wanted to add that @haesleinhuepf 's question seems well-poised and clear enough to me. I encountered a the same error while trying to run an example for
Fine for who? It doesn't fix the error I'm encountering. It's not immediately obvious how removal of |
it's trivial to figure out what happened -- teaching one to fish: $ git log -G ReturnWithArgsInsideGenerator | head -5
commit 2246217295dc8cb30ef4a7b9d8dc449ce32e603a
Author: Anthony Sottile <[email protected]>
Date: Sun Jun 12 17:07:21 2022 -0400
burn the bridges with python 2.x (#707)
asottile@asottile-sentry:/tmp/pyflakes
$ git show --format= 2246217295dc8cb30ef4a7b9d8dc449ce32e603a -- pyflakes/messages.py | cat
diff --git a/pyflakes/messages.py b/pyflakes/messages.py
index 5a2f0ce..2d08112 100644
--- a/pyflakes/messages.py
+++ b/pyflakes/messages.py
@@ -3,18 +3,18 @@ Provide the class Message and its subclasses.
"""
-class Message(object):
+class Message:
message = ''
message_args = ()
def __init__(self, filename, loc):
self.filename = filename
self.lineno = loc.lineno
- self.col = getattr(loc, 'col_offset', 0)
+ self.col = loc.col_offset
def __str__(self):
- return '%s:%s:%s: %s' % (self.filename, self.lineno, self.col+1,
- self.message % self.message_args)
+ return '{}:{}:{}: {}'.format(self.filename, self.lineno, self.col+1,
+ self.message % self.message_args)
class UnusedImport(Message):
@@ -33,14 +33,6 @@ class RedefinedWhileUnused(Message):
self.message_args = (name, orig_loc.lineno)
-class RedefinedInListComp(Message):
- message = 'list comprehension redefines %r from line %r'
-
- def __init__(self, filename, loc, name, orig_loc):
- Message.__init__(self, filename, loc)
- self.message_args = (name, orig_loc.lineno)
-
-
class ImportShadowedByLoopVar(Message):
message = 'import %r from line %r shadowed by loop variable'
@@ -168,13 +160,6 @@ class UnusedVariable(Message):
self.message_args = (names,)
-class ReturnWithArgsInsideGenerator(Message):
- """
- Indicates a return statement with arguments inside a generator.
- """
- message = '\'return\' with argument inside generator'
-
-
class ReturnOutsideFunction(Message):
"""
Indicates a return statement outside of a function/method.
if you're integrating with pyflakes as a library it's kinda on you to keep up with the changes -- we can't be responsible for your integrations. the implementation of the pyflakes tool isn't a public interface (entirely undocumented) or really supported so using the internals in that way is at your own support (this is the reason for example flake8 carefully selects the versions of pyflakes) |
Thank you @asottile for taking the time to reply. All I see in the diff is that the function was removed, which I agree is trivial and the part that I could do on my own without help from the community. Unfortunately this does little to help me resolve the problem or answer the question asked. The second part of your comment on the other hand better explains the situation (and why a changing public interface isn't this library's problem and can't be expected or relied upon). Furthermore suggests a potential solution for the issue (carefully select and pin the version of pyflakes in my library like flake8 does). Thanks again for your time and consideration. |
Hi all,
I just noticed that the napari-script-editor, a plugin I maintain, stopped working with pyflakes 2.5.0 because this function is missing from the API (full error log below):
I'm just wondering, is there some transition guide for how to update dependent code from pyflakes 2.4.0 to 2.5.0 ?
Thanks!
Best,
Robert
Full error log:
The text was updated successfully, but these errors were encountered: