forked from pylint-dev/pylint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refs pylint-dev#9069 Refs pylint-dev/astroid#2305
- Loading branch information
Showing
2 changed files
with
54 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# pylint: disable=missing-module-docstring, invalid-name, missing-class-docstring, unused-variable | ||
|
||
|
||
from dataclasses import dataclass | ||
from typing import Generic, TypeVar | ||
|
||
|
||
T_Inner = TypeVar("T_Inner", bound="Inner") | ||
|
||
|
||
@dataclass | ||
class Inner: | ||
inner_attribute: str | ||
|
||
|
||
@dataclass | ||
class Outer(Generic[T_Inner]): | ||
inner: T_Inner | ||
|
||
|
||
x = Outer(inner=Inner(inner_attribute="magic xylophone")) | ||
|
||
# Test `no-member` is not emitted here. | ||
# https://github.com/pylint-dev/pylint/issues/9069 | ||
print(x.inner.inner_attribute) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,34 @@ | ||
"""Tests for unscubscriptable-object""" | ||
|
||
# Test for typing.NamedTuple | ||
# See: https://github.com/pylint-dev/pylint/issues/1295 | ||
# pylint: disable=unused-variable, too-few-public-methods | ||
|
||
import typing | ||
|
||
from collections.abc import Mapping | ||
from typing import Generic, TypeVar, TypedDict | ||
from dataclasses import dataclass | ||
|
||
# Test for typing.NamedTuple | ||
# See: https://github.com/pylint-dev/pylint/issues/1295 | ||
MyType = typing.Tuple[str, str] | ||
|
||
|
||
# https://github.com/pylint-dev/astroid/issues/2305 | ||
class Identity(TypedDict): | ||
"""It's the identity.""" | ||
|
||
name: str | ||
|
||
T = TypeVar("T", bound=Mapping) | ||
|
||
@dataclass | ||
class Animal(Generic[T]): | ||
"""It's an animal.""" | ||
|
||
identity: T | ||
|
||
class Dog(Animal[Identity]): | ||
"""It's a Dog.""" | ||
|
||
dog = Dog(identity=Identity(name="Dog")) | ||
print(dog.identity["name"]) |