Skip to content

Commit b2afb38

Browse files
committed
Add regression tests.
Refs pylint-dev#9069 Refs pylint-dev/astroid#2305
1 parent a4aff97 commit b2afb38

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# pylint: disable=missing-module-docstring, invalid-name, missing-class-docstring, unused-variable
2+
3+
4+
from dataclasses import dataclass
5+
from typing import Generic, TypeVar
6+
7+
8+
T_Inner = TypeVar("T_Inner", bound="Inner")
9+
10+
11+
@dataclass
12+
class Inner:
13+
inner_attribute: str
14+
15+
16+
@dataclass
17+
class Outer(Generic[T_Inner]):
18+
inner: T_Inner
19+
20+
21+
x = Outer(inner=Inner(inner_attribute="magic xylophone"))
22+
23+
# Test `no-member` is not emitted here.
24+
# https://github.com/pylint-dev/pylint/issues/9069
25+
print(x.inner.inner_attribute)
Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,34 @@
11
"""Tests for unscubscriptable-object"""
22

3-
# Test for typing.NamedTuple
4-
# See: https://github.com/pylint-dev/pylint/issues/1295
3+
# pylint: disable=unused-variable, too-few-public-methods
4+
55
import typing
66

7+
from collections.abc import Mapping
8+
from typing import Generic, TypeVar, TypedDict
9+
from dataclasses import dataclass
10+
11+
# Test for typing.NamedTuple
12+
# See: https://github.com/pylint-dev/pylint/issues/1295
713
MyType = typing.Tuple[str, str]
14+
15+
16+
# https://github.com/pylint-dev/astroid/issues/2305
17+
class Identity(TypedDict):
18+
"""It's the identity."""
19+
20+
name: str
21+
22+
T = TypeVar("T", bound=Mapping)
23+
24+
@dataclass
25+
class Animal(Generic[T]):
26+
"""It's an animal."""
27+
28+
identity: T
29+
30+
class Dog(Animal[Identity]):
31+
"""It's a Dog."""
32+
33+
dog = Dog(identity=Identity(name="Dog"))
34+
print(dog.identity["name"])

0 commit comments

Comments
 (0)