-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
pylint-dev/astroid
#2848Labels
AstroidRelated to astroidRelated to astroidFalse Positive 🦟A message is emitted but nothing is wrong with the codeA message is emitted but nothing is wrong with the codeGood first issueFriendly and approachable by new contributorsFriendly and approachable by new contributorsHelp wanted 🙏Outside help would be appreciated, good for new contributorsOutside help would be appreciated, good for new contributorsNeeds PRThis issue is accepted, sufficiently specified and now needs an implementationThis issue is accepted, sufficiently specified and now needs an implementationNeeds astroid constraint
Description
Bug description
Steps to reproduce:
class Model:
field: list[int] | None = None
def method(self):
return [f + 1 for f in self.field] if self.field else None
if __name__ == "__main__":
pass
NB: If replace `field: list[int] | None = None` with `field: list[int] | None` it works as expected
Configuration
No response
Command used
pylint filename.py
Pylint output
E1133: Non-iterable value self.field is used in an iterating context (not-an-iterable)
Expected behavior
No error
Pylint version
3.2.3
OS / Environment
MacOS 14.4.1
Python 3.12.0
Additional dependencies
No response
Metadata
Metadata
Assignees
Labels
AstroidRelated to astroidRelated to astroidFalse Positive 🦟A message is emitted but nothing is wrong with the codeA message is emitted but nothing is wrong with the codeGood first issueFriendly and approachable by new contributorsFriendly and approachable by new contributorsHelp wanted 🙏Outside help would be appreciated, good for new contributorsOutside help would be appreciated, good for new contributorsNeeds PRThis issue is accepted, sufficiently specified and now needs an implementationThis issue is accepted, sufficiently specified and now needs an implementationNeeds astroid constraint