I am upgrading a plugin from 2.13 to 2.14 and am s...
# plugins
f
I am upgrading a plugin from 2.13 to 2.14 and am struggling with a
FieldSet
.
1
In the docs, it says I have to use
FieldSet
in the
infer_from
which I do:
Copy code
@dataclass(frozen=True)
class InferDependencyGlobsRequestFieldSet(FieldSet):
    required_fields = (MyDependencies, DependencyGlobsField)
    dependencies: MyDependencies
    globs: DependencyGlobsField

class InferDependencyGlobsRequest(InferDependenciesRequest):
    infer_from = InferDependencyGlobsRequestFieldSet

...

@rule
async def find_dependencies_by_glob(
    request: InferDependencyGlobsRequest,
) -> InferredDependencies:
    <http://logger.info|logger.info>(request.infer_from.dependencies)
    ...
I get
AttributeError: type object 'InferDependencyGlobsRequestFieldSet' has no attribute 'dependencies'
. But clearly
dependencies
is in the dataclass definition? 😕 Doing
<http://logger.info|logger.info>
gives me
'applicable_target_types', 'create', 'debug_hint', 'is_applicable', 'metadata', 'opt_out', 'required_fields'
for public attributes.
f
maybe remove the
@dataclass
decorator on your
FieldSet
subclass because
FieldSet
now has that decorator?
never mind, looks like that pattern is used for other similar field sets
what does
MyDependencies
look like?
oh
you want
request.field_set
infer_from
is a
ClassVar
the actual
FieldSet
instance is an instance attribute called
field_set
f
oh thank you @fast-nail-55400 so much. Coding late wasn't a great idea! 😄 the plugin works fine now
👍 1