Skip to content

Commit a3464cb

Browse files
Add a test for false positive no-member in subclassed dataclasses
Closes #3754
1 parent 7a9bfc4 commit a3464cb

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
from abc import ABCMeta, abstractmethod
2+
import dataclasses as dc
3+
from typing import Any, Dict
4+
5+
@dc.dataclass(frozen=True)
6+
class DeploymentState(metaclass=ABCMeta):
7+
type: str
8+
9+
@abstractmethod
10+
def to_dict(self) -> Dict:
11+
"""
12+
Serializes given DeploymentState instance to Dict.
13+
:return:
14+
"""
15+
16+
@dc.dataclass(frozen=True)
17+
class DeploymentStateEcs(DeploymentState):
18+
blue: Any
19+
green: Any
20+
candidate: Any
21+
22+
def to_dict(self) -> Dict:
23+
return {
24+
'type': self.type,
25+
'blue': dc.asdict(self.blue),
26+
'green': dc.asdict(self.green),
27+
'candidate': self.candidate.value,
28+
}
29+
30+
@dc.dataclass(frozen=True)
31+
class DeploymentStateLambda(DeploymentState):
32+
current: Any
33+
candidate: Any
34+
35+
def to_dict(self) -> Dict:
36+
return {
37+
'type': self.type,
38+
'current': dc.asdict(self.current),
39+
'candidate': dc.asdict(self.candidate) if self.candidate else None,
40+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[testoptions]
2+
min_pyver=3.7
3+
4+
[MESSAGES CONTROL]
5+
disable=fixme,
6+
logging-too-many-args,
7+
logging-fstring-interpolation,
8+
missing-docstring,
9+
no-else-return,
10+
too-few-public-methods,

0 commit comments

Comments
 (0)