-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Suggestion: Creation of a dummy placeholder so that mypy doesn't return a "already defined" error when the re-definition is required. #3284
Comments
Hello, Thanks for the solution. I'll keep the suggestion open. Best regards, JM |
Hello, Tried your solution, but mypy returns this error
had to change it to Thanks, JM |
@ilevkivskyi @ddfisher The failure from the last comment (presumably with strict optional) seems to be in violation of what PEP 484 says about this... |
Yeah, we decided to punt on the implementation of that until mypy had undefined checking. (We discussed this at the time, but that was a while ago now.) |
Hello, Maybe _ could be the placeholder?
would become this
Thanks, JM |
Has there been any update on this issue to provide a placeholder value? Im getting that same error ('"None" has no attribute cursor') when using a placeholder of None in my init() function that gets redefined in the the connect() function. Not sure how I can resolve this. Thanks in advance for the help!
|
Add a type hint in Closing the original issue since type comments are discouraged and there's no analogue for the above use case in PEP 526 |
Thanks @hauntsaninja ! |
For anyone coming across this later, this is what I did:
|
Hello,
I would like to suggest the creation of a dummy placeholder (eg. AlreadyDefined or some symbol like ! or ...) so that mypy doesn't return a "already defined" error when the re-definition is required.
Here are 2 examples:
With the examples code above, mypy tells me that
data_processing.py:144: error: Name 'row' already defined
which is correct, but annoying, because to identify the type of event, I must re-identify row.
I know that I could disable the "already defined" errors with a command line flag, but I would like to receive them except when I have to re-identify some vars due to others, like in the examples above.
Thanks,
JM
The text was updated successfully, but these errors were encountered: