This is a known issue of pyreverse:
- Issue #8046 -> Opened in January, and still unresolved
- Issue #8189 -> Opened in February, and still unresolved
There are two issues, depending on whether a value is assigned at class level or only a type annotation at class level. The co-author of pyreverse explains in the issue log the subtle difference: the value assignment at class level would cause two pair of variables exist: one at instance level and one at class level. This is why the first is issue is categorised as enhancement and the second as bug.
Once the issues are resolved, your code should produce a class with only two instance variables and the right annotation, whereas the following code would produce similar output to yours, but one of each duplicate would be marked as static (class variable):
class Example:
var_a: int = 5
var_b: str = "six"
def __init__(self, var_a, var_b) -> None:
self.var_a = var_a
self.var_b = var_b
def test(self):
print (self.var_a, self.var_b)
@classmethod
def classtest(cls):
print (cls.var_a, cls.var_b)
The bad news is that there seem currently to be no ongoing work to solve those issues. So, meanwhile, the the workaround would probably be to comment out the definition at class level and embedded the type annotation in the init. I agree that this is far from ideal.