ayon-core icon indicating copy to clipboard operation
ayon-core copied to clipboard

Make `PublishAttributeValues` behave like `dict` when iterating

Open BigRoy opened this issue 6 months ago • 0 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues.

Please describe the feature you have in mind and explain what the current shortcomings are?

For whatever reason it seems that iterating a PublishAttributeValues instance is possible but does not behave like a standard dict which makes it confusing.

See:

I'm not sure why but this object when iterating over it yields e.g. 0 etc. https://github.com/ynput/ayon-core/blob/05f6b0f2ce000910004c3ce9913e17ec528bc04b/client/ayon_core/pipeline/create/context.py#L670

I'd expect that to be non-iterable OR iterate like a dict over the keys by default? Error was faced here: https://github.com/ynput/ayon-maya/pull/40#issuecomment-2255594300 I'm not sure why python allows it to be iterable to begin with 😄 Maybe due to the implementation of __contains__ but not __iter__?

How would you imagine the implementation of the feature?

Implement __iter__ to explicitly iterate the keys? Or force it to be non-iterable to avoid confusion.

Are there any labels you wish to add?

  • [X] I have added the relevant labels to the enhancement request.

Describe alternatives you've considered:

No response

Additional context:

No response

BigRoy avatar Jul 29 '24 13:07 BigRoy