-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Update astroid to 3.2.2 * Add tests for generic class syntax (cherry picked from commit 032ab32) Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
- Loading branch information
1 parent
9223172
commit 9a9db8f
Showing
7 changed files
with
80 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,3 @@ | ||
Fix multiple false positives for generic class syntax added in Python 3.12 (PEP 695). | ||
|
||
Closes #9406 |
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
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
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,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 |
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,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 |
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,2 @@ | ||
[testoptions] | ||
min_pyver=3.12 |
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,2 @@ | ||
undefined-variable:5:29:5:31:Entity.__init__:Undefined variable '_T':UNDEFINED | ||
undefined-variable:31:23:31:25:Child:Undefined variable '_T':UNDEFINED |