-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
base: main
Are you sure you want to change the base?
scripts: twister: Make TwisterStatus autocasting more intuitive #77168
Conversation
@@ -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 |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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.
This PR's tests should be rerun before merging if #77080 is merged before it. |
659ca34
to
763999c
Compare
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]>
763999c
to
86ebfa7
Compare
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 toTwisterStatus.NONE
.