Sobes.tech
Junior — Senior

Detect defects in the provided Python script

livecode

Task condition

The provided code snippet contains several logical and type-related errors. Analyze it and identify the problematic areas.


from __future__ import annotations
import dataclasses

class Parent:
    def method(self) -> int:
        return 1

@dataclasses.dataclass(slots=True)
class Child[T: int](Parent):
    x: T
    y: list[int] = dataclasses.field(default_factory=list)

    def method(self) -> str:
        return self.x + len(self.y) + super().method()  # XXX

inst = Child(y=[1], x=5.5)
print(inst.method())