diff options
author | Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com> | 2021-09-14 10:43:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-14 10:43:56 +0200 |
commit | bc95cd34071ec2e71de5bca8ff95cc9b88e23814 (patch) | |
tree | 55931e70773993875937b859373f947696835456 | |
parent | ca455ce7914cc41a51ea03e5201106f0f4de074d (diff) | |
download | pylint-git-bc95cd34071ec2e71de5bca8ff95cc9b88e23814.tar.gz |
Add tests for dataclasses (#4967)
* Add tests for dataclasses
This closes #4963 and is based on the fix in PyCQA/astroid#1165
-rw-r--r-- | tests/functional/d/dataclass_with_default_factory.py | 7 | ||||
-rw-r--r-- | tests/functional/d/dataclass_with_default_factory.txt | 4 |
2 files changed, 9 insertions, 2 deletions
diff --git a/tests/functional/d/dataclass_with_default_factory.py b/tests/functional/d/dataclass_with_default_factory.py index 8f24d5e6e..db392d8b7 100644 --- a/tests/functional/d/dataclass_with_default_factory.py +++ b/tests/functional/d/dataclass_with_default_factory.py @@ -4,6 +4,7 @@ # - https://github.com/PyCQA/pylint/issues/2698 from dataclasses import dataclass, field import dataclasses as dc +from typing import cast @dataclass @@ -41,3 +42,9 @@ for _ in Test2.int_prop: # [not-an-iterable] Test2.int_prop["key"] = "value" # [unsupported-assignment-operation] + + +@dc.dataclass +class TEST3: + """Test dataclass that puts call to field() in another function call""" + attribute: int = cast(int, field(default_factory=dict)) diff --git a/tests/functional/d/dataclass_with_default_factory.txt b/tests/functional/d/dataclass_with_default_factory.txt index c33a7d3a4..af789b14a 100644 --- a/tests/functional/d/dataclass_with_default_factory.txt +++ b/tests/functional/d/dataclass_with_default_factory.txt @@ -1,2 +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 +not-an-iterable:40:9::Non-iterable value Test2.int_prop is used in an iterating context:HIGH +unsupported-assignment-operation:44:0::'Test2.int_prop' does not support item assignment:HIGH |