-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 for astroid 2.7.0 fixes #4816
Merged
Pierre-Sassoulas
merged 5 commits into
pylint-dev:main
from
Pierre-Sassoulas:regression-test-533-2224-2626
Aug 16, 2021
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
12097bd
Fix functional test no-value-for-parameter when instancing an enum
Pierre-Sassoulas ba459f7
Add regression tests for issue with subclassed enums
Pierre-Sassoulas 254824e
Additional tests for PyCQA/astroid#1126
david-yz-liu dffdc1f
Upgrade astroid to 2.7.0
Pierre-Sassoulas 5244b33
Limit the dataclasses tests to python 3.7
Pierre-Sassoulas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
-e . | ||
astroid==2.6.6 # Pinned to a specific version for tests | ||
astroid==2.7.0 # Pinned to a specific version for tests | ||
pytest~=6.2 | ||
pytest-benchmark~=3.4 |
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
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 @@ | ||
not-an-iterable:39:9::Non-iterable value Test2.int_prop is used in an iterating context:HIGH | ||
unsupported-assignment-operation:43:0::'Test2.int_prop' does not support item assignment:HIGH |
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,11 @@ | ||
""" Regression test for https://github.com/PyCQA/pylint/issues/3405. """ | ||
|
||
import dataclasses | ||
from typing import ClassVar | ||
|
||
|
||
@dataclasses.dataclass | ||
class Foo: | ||
"""ClassVar attribute should be matched against class-attribute-rgx, not attr-rgx""" | ||
# class-attribute-rgx='^y$' | ||
x: ClassVar[int] = 0 # [invalid-name] |
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,9 @@ | ||
[MESSAGES CONTROL] | ||
enable=invalid-name | ||
|
||
[BASIC] | ||
attr-rgx=^x$ | ||
class-attribute-rgx=^y$ | ||
|
||
[testoptions] | ||
min_pyver=3.7 |
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 @@ | ||
invalid-name:11:4:Foo:"Class attribute name ""x"" doesn't conform to '^y$' pattern":HIGH |
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,83 @@ | ||
"""Test various regressions for dataclasses and no-member. | ||
""" | ||
# pylint: disable=missing-docstring, too-few-public-methods | ||
from abc import ABCMeta, abstractmethod | ||
from dataclasses import asdict, dataclass, field | ||
from typing import Any, Dict | ||
|
||
|
||
# https://github.com/PyCQA/pylint/issues/3754 | ||
@dataclass(frozen=True) | ||
class DeploymentState(metaclass=ABCMeta): | ||
type: str | ||
|
||
@abstractmethod | ||
def to_dict(self) -> Dict: | ||
""" | ||
Serializes given DeploymentState instance to Dict. | ||
:return: | ||
""" | ||
|
||
|
||
@dataclass(frozen=True) | ||
class DeploymentStateEcs(DeploymentState): | ||
blue: Any | ||
green: Any | ||
candidate: Any | ||
|
||
def to_dict(self) -> Dict: | ||
return { | ||
'type': self.type, # No error here | ||
'blue': asdict(self.blue), | ||
'green': asdict(self.green), | ||
'candidate': self.candidate.value, | ||
} | ||
|
||
|
||
@dataclass(frozen=True) | ||
class DeploymentStateLambda(DeploymentState): | ||
current: Any | ||
candidate: Any | ||
|
||
def to_dict(self) -> Dict: | ||
return { | ||
'type': self.type, # No error here | ||
'current': asdict(self.current), | ||
'candidate': asdict(self.candidate) if self.candidate else None, | ||
} | ||
|
||
|
||
# https://github.com/PyCQA/pylint/issues/2600 | ||
@dataclass | ||
class TestClass: | ||
attr1: str | ||
attr2: str | ||
dict_prop: Dict[str, str] = field(default_factory=dict) | ||
|
||
def some_func(self) -> None: | ||
for key, value in self.dict_prop.items(): # No error here | ||
print(key) | ||
print(value) | ||
|
||
|
||
class TestClass2: # not a dataclass, field inferred to a Field | ||
attr1: str | ||
attr2: str | ||
dict_prop: Dict[str, str] = field(default_factory=dict) | ||
|
||
def some_func(self) -> None: | ||
for key, value in self.dict_prop.items(): # [no-member] | ||
print(key) | ||
print(value) | ||
|
||
|
||
@dataclass | ||
class TestClass3: | ||
attr1: str | ||
attr2: str | ||
dict_prop = field(default_factory=dict) # No type annotation, not treated as field | ||
|
||
def some_func(self) -> None: | ||
for key, value in self.dict_prop.items(): # [no-member] | ||
print(key) | ||
print(value) |
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.7 |
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 @@ | ||
no-member:69:26:TestClass2.some_func:Instance of 'Field' has no 'items' member:INFERENCE | ||
no-member:81:26:TestClass3.some_func:Instance of 'Field' has no 'items' member:INFERENCE |
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 |
---|---|---|
@@ -1 +1 @@ | ||
too-many-instance-attributes:3:0:Aaaa:Too many instance attributes (21/7) | ||
too-many-instance-attributes:5:0:Aaaa:Too many instance attributes (21/7):HIGH |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Pierre-Sassoulas this was an oversight on my part---
dataclasses
was introduced in Python 3.7, which is why the tests are failing on 3.6. I think the right fix is to move this test into a separate file do do themin_pyver
configuration?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes there are other example in the functional test. (same name with _py37 would work). You made the code we'll need in 4 months :) We need to support python 3.6 until its end of life, but it's close now.