-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
False positive used-before-assignment for variable annotations when using TYPE_CHECKING #7609
Labels
C: used-before-assignment
Issues related to 'used-before-assignment' check
False Positive 🦟
A message is emitted but nothing is wrong with the code
Needs PR
This issue is accepted, sufficiently specified and now needs an implementation
typing
Milestone
Comments
mew1033
added
the
Needs triage 📥
Just created, needs acknowledgment, triage, and proper labelling
label
Oct 11, 2022
mbyrnepr2
added
Cannot reproduce 🤷
and removed
Needs triage 📥
Just created, needs acknowledgment, triage, and proper labelling
labels
Oct 12, 2022
Thanks for reporting this @mew1033. Can you please provide a minimal reproducible example to help us dig into this one? |
mbyrnepr2
added
the
Waiting on author
Indicate that maintainers are waiting for a message of the author
label
Oct 12, 2022
@mbyrnepr2 So sorry, I got the example ready and then completely forgot to add it to the issue. Here's a snippet that shows the issue. If you remove the from typing import TYPE_CHECKING
import boto3
if TYPE_CHECKING:
from mypy_boto3_sns.type_defs import PublishBatchRequestEntryTypeDef
def publish_to_sns():
"""
Create SNS messages and publish them
"""
sns_client = boto3.client("sns")
messages: list[PublishBatchRequestEntryTypeDef] = [] |
No worries - thank you! |
mbyrnepr2
added
Needs investigation 🔬
A bug or crash where it's not immediately obvious what is happenning
and removed
Cannot reproduce 🤷
Waiting on author
Indicate that maintainers are waiting for a message of the author
labels
Oct 13, 2022
jacobtylerwalls
added
False Positive 🦟
A message is emitted but nothing is wrong with the code
C: used-before-assignment
Issues related to 'used-before-assignment' check
and removed
Needs investigation 🔬
A bug or crash where it's not immediately obvious what is happenning
labels
Oct 14, 2022
jacobtylerwalls
changed the title
False positive used-before-assignment when using TYPE_CHECKING
False positive used-before-assignment for variable annotations when using TYPE_CHECKING
Oct 14, 2022
jacobtylerwalls
added
the
Needs PR
This issue is accepted, sufficiently specified and now needs an implementation
label
Oct 14, 2022
This was referenced Nov 20, 2022
Some helpful test cases given in #7773 |
This was referenced Jan 16, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
C: used-before-assignment
Issues related to 'used-before-assignment' check
False Positive 🦟
A message is emitted but nothing is wrong with the code
Needs PR
This issue is accepted, sufficiently specified and now needs an implementation
typing
Bug description
I know this has been looked at before, but I just ran into it again with pylint 2.15.4. If an import is guarded behind TYPE_CHECKING, I'm getting an
used-before-assignment
error when using that import in a type definition.Configuration
No response
Command used
Pylint output
file.py:7:19: E0601: Using variable 'PublishBatchRequestEntryTypeDef' before assignment (used-before-assignment)
Expected behavior
It shouldn't error
Pylint version
OS / Environment
No response
Additional dependencies
No response
The text was updated successfully, but these errors were encountered: