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

Update astroid to 3.2.2 #9655

Merged
merged 4 commits into from
May 20, 2024
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
3 changes: 3 additions & 0 deletions doc/whatsnew/fragments/9406.false_positive
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix multiple false positives for generic class syntax added in Python 3.12 (PEP 695).

Closes #9406
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.2.1,<=3.3.0-dev0",
"astroid>=3.2.2,<=3.3.0-dev0",
"isort>=4.2.5,<6,!=5.13.0",
"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.2.1 # Pinned to a specific version for tests
astroid==3.2.2 # Pinned to a specific version for tests
typing-extensions~=4.11
py~=1.11.0
pytest~=7.4
Expand Down
38 changes: 38 additions & 0 deletions tests/functional/g/generic_class_syntax.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# pylint: disable=missing-docstring,too-few-public-methods
from typing import Generic, TypeVar, Optional

_T = TypeVar("_T")


class Entity(Generic[_T]):
last_update: Optional[int] = None

def __init__(self, data: _T) -> None:
self.data = data


class Sensor(Entity[int]):
def __init__(self, data: int) -> None:
super().__init__(data)

def async_update(self) -> None:
self.data = 2

if self.last_update is None:
pass
self.last_update = 2


class Switch(Entity[int]):
def __init__(self, data: int) -> None:
Entity.__init__(self, data)


class Parent(Generic[_T]):
def __init__(self):
self.update_interval = 0


class Child(Parent[_T]):
def func(self):
self.update_interval = None
33 changes: 33 additions & 0 deletions tests/functional/g/generic_class_syntax_py312.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# pylint: disable=missing-docstring,too-few-public-methods
class Entity[_T: float]:
last_update: int | None = None

def __init__(self, data: _T) -> None: # [undefined-variable] # false-positive
self.data = data


class Sensor(Entity[int]):
def __init__(self, data: int) -> None:
super().__init__(data)

def async_update(self) -> None:
self.data = 2

if self.last_update is None:
pass
self.last_update = 2


class Switch(Entity[int]):
def __init__(self, data: int) -> None:
Entity.__init__(self, data)


class Parent[_T]:
def __init__(self):
self.update_interval = 0


class Child[_T](Parent[_T]): # [undefined-variable] # false-positive
def func(self):
self.update_interval = None
2 changes: 2 additions & 0 deletions tests/functional/g/generic_class_syntax_py312.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[testoptions]
min_pyver=3.12
2 changes: 2 additions & 0 deletions tests/functional/g/generic_class_syntax_py312.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
undefined-variable:5:29:5:31:Entity.__init__:Undefined variable '_T':UNDEFINED
undefined-variable:31:23:31:25:Child:Undefined variable '_T':UNDEFINED
Loading