Skip to content

Commit

Permalink
Add regression tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbyrnepr2 committed Sep 26, 2023
1 parent a4aff97 commit b2afb38
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 2 deletions.
25 changes: 25 additions & 0 deletions tests/functional/n/no/no_member_typevar.py
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:/pylint-dev/pylint/issues/9069
print(x.inner.inner_attribute)
31 changes: 29 additions & 2 deletions tests/functional/u/unsubscriptable_object.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,34 @@
"""Tests for unscubscriptable-object"""

# Test for typing.NamedTuple
# See: https:/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:/pylint-dev/pylint/issues/1295
MyType = typing.Tuple[str, str]


# https:/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"])

0 comments on commit b2afb38

Please sign in to comment.