Skip to content

Commit

Permalink
Add tests for PyCQA#5767
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielNoord committed Aug 24, 2022
1 parent bf8281c commit 32116ae
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
3 changes: 3 additions & 0 deletions doc/whatsnew/fragments/5767.false_positive
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Don't report ``no-value-for-parameter`` for dataclasses fields annotated with ``KW_ONLY``.

Closes #5767
27 changes: 27 additions & 0 deletions tests/functional/d/dataclass_parameter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""Tests for dataclass and checks that check for parameters."""

import dataclasses
from dataclasses import KW_ONLY as keyword_only
from dataclasses import dataclass


@dataclass
class MyDataClass:
"""Simple dataclass with a KW_ONLY parameter."""

_: dataclasses.KW_ONLY
data: str


MyDataClass(data="test")


@dataclass
class MyDataClassWithAliases:
"""Simple dataclass with an aliased KW_ONLY parameter."""

_: keyword_only
data: str


MyDataClassWithAliases(data="test")
2 changes: 2 additions & 0 deletions tests/functional/d/dataclass_parameter.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[testoptions]
min_pyver=3.10

0 comments on commit 32116ae

Please sign in to comment.