-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Thanks for reporting this @mew1033. Can you please provide a minimal reproducible example to help us dig into this one? |
@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! |
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: