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 tests for dataclasses #4967

Merged
merged 2 commits into from
Sep 14, 2021
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
7 changes: 7 additions & 0 deletions tests/functional/d/dataclass_with_default_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -41,3 +42,9 @@ class Test2:


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))
4 changes: 2 additions & 2 deletions tests/functional/d/dataclass_with_default_factory.txt
Original file line number Diff line number Diff line change
@@ -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