-
-
Notifications
You must be signed in to change notification settings - Fork 713
Description
I added a new attribute to the Resource class when using VirtualCodebase like so:
plugin_attributes = dict(matches=attr.ib(default=attr.Factory(list)))
vc = VirtualCodebase(
json_scan_location=self.input_file.path,
plugin_attributes=plugin_attributes
)
When I add a new attribute to the Resource class when using VirtualCodebase, I expect my new attribute to show up at the end of all the other attributes that already exist from the attributes collected from the input scan file. What happens when I export the codebase to JSON is that the new attribute shows up in front or in the middle of all the other attributes.
It turns out that the attributes classes created by attrs have a counter attribute that dictates attribute order. I worked around this issue by doing this:
matches = attr.ib(default=attr.Factory(list))
matches.counter = 50
plugin_attributes = dict(matches=matches)
vc = VirtualCodebase(
json_scan_location=self.input_file.path,
plugin_attributes=plugin_attributes
)
Now, the new matches attribute is at the end of all the other attributes, as desired.
It would be nice to have a way to not have to do this workaround when adding new attributes to Resources in a VirtualCodebase.