Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scripts: twister: Make TwisterStatus autocasting more intuitive #77168

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

LukaszMrugala
Copy link
Collaborator

Rather than writing the Enum key names, like 'FILTER', users probably would be more at-home using the same terms as they can find in their Twister reports, e.g. 'filtered'. None will also be accepted and converted to TwisterStatus.NONE.

@LukaszMrugala LukaszMrugala added DNM This PR should not be merged (Do Not Merge) and removed DNM This PR should not be merged (Do Not Merge) labels Aug 16, 2024
@LukaszMrugala LukaszMrugala marked this pull request as ready for review August 19, 2024 10:01
@@ -102,8 +102,8 @@ def status(self) -> TwisterStatus:
def status(self, value : TwisterStatus) -> None:
# Check for illegal assignments by value
try:
key = value.name if isinstance(value, Enum) else value
self._status = TwisterStatus[key]
key = value.value if isinstance(value, Enum) else value
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this common code be just at one place - as a setter of TwisterStatus class - while there is no instance/harness/suite specifics in assignment ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setters are for a property of a class, not the class itself - thus, setters are in classes containing TwisterStatus Enum, not in Enum itself.

You could make a kind-of-a-hack via overloading the _missing_ method of the Enum to do just self._status = TwisterStatus(value) here, where value must not collide with another Enum value and the it will go into _missing_ method in the Enum where we could do casting, checking, etc. It's not very Pythonic, I'd say.

nashif
nashif previously approved these changes Aug 20, 2024
@LukaszMrugala
Copy link
Collaborator Author

This PR's tests should be rerun before merging if #77080 is merged before it.

Rather than writing the Enum key names, like 'FILTER',
users probably would be more at-home using the same terms
as they can find in their Twister reports, e.g. 'filtered'.

Signed-off-by: Lukasz Mrugala <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants