teemtee / tmt

Test Management Tool
MIT License
76 stars 112 forks source link

Plugins cannot be `dataclass` or `attrs` #2864

Open LecrisUT opened 1 month ago

LecrisUT commented 1 month ago

I was trying to do:

@tmt.steps.provides_method("copr")
@attrs.define
class DiscoverCopr(DiscoverPlugin[DiscoverCoprData]):
    _tests: list[tmt.Test] = attrs.field(factory=list, init=False)

But this doesn't work because it doesn't inherit the parent's **kwargs

DiscoverCopr.__init__() got an unexpected keyword argument 'logger'

Same story for dataclasses.

Using init=False is not useful because it gets populated with the traceback instead of the actual factory :shrug:. I have tried changing the order of the decorators, but that left the field un-initialized.