Skip to content

Commit 042717c

Browse files
authored
Add regression test for false positive on Optional List (#10676)
1 parent 4eabe26 commit 042717c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/functional/u/unsubscriptable_object.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,15 @@ class Dog(Animal[Identity]):
3232

3333
DOG = Dog(identity=Identity(name="Dog"))
3434
print(DOG.identity["name"])
35+
36+
37+
# Regression test for https://github.com/pylint-dev/pylint/issues/9515
38+
class Parents(): # pylint: disable=missing-class-docstring, missing-function-docstring
39+
name: str
40+
age: int
41+
children_name: typing.Optional[list[str]] = None
42+
43+
def get_first_children_name(self) -> typing.Optional[str]:
44+
if self.children_name:
45+
return self.children_name[0]
46+
return None

0 commit comments

Comments
 (0)