Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add regression tests. #9071

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ dependencies = [
# Also upgrade requirements_test_min.txt.
# Pinned to dev of second minor update to allow editable installs and fix primer issues,
# see https://github.com/pylint-dev/astroid/issues/1341
"astroid>=3.0.0b0,<=3.1.0-dev0",
"astroid>=3.0.0,<=3.1.0-dev0",
"isort>=4.2.5,<6",
"mccabe>=0.6,<0.8",
"tomli>=1.1.0;python_version<'3.11'",
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_min.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.[testutils,spelling]
# astroid dependency is also defined in pyproject.toml
astroid==3.0.0b0 # Pinned to a specific version for tests
astroid==3.0.0 # Pinned to a specific version for tests
typing-extensions~=4.8
py~=1.11.0
pytest~=7.4
Expand Down
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://github.com/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://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"])