-
-
Notifications
You must be signed in to change notification settings - Fork 746
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
Fix TypeError in help command by handling mixed parameter types for sorting #6266
base: master
Are you sure you want to change the base?
Fix TypeError in help command by handling mixed parameter types for sorting #6266
Conversation
…d optional parameters
|
@nzlosh @cognifloyd can you check getting lint error again and again adjusted the file according to black format still |
@amanda11 @nzlosh |
Converting position to string will change the sort order; for example |
@cognifloyd made some changes but does it look like , is this change feasible to apply |
The logic is now pretty much the same as before. I think a clean way to solve this would be to create a custom object wrapper that handles sorting comparisons. The object would wrap either |
Something like this (ignore the class it can be updated later & mainly focus on logic)
|
Summary:
This PR addresses the issue where the
st2 run action pack.action -h
command fails with aTypeError: '<' not supported between instances of 'str' and 'int'
. The error occurs when sorting action parameters that have a mix of names (strings) and positions (integers). In Python 3, comparing these types directly causes a failure.Root Cause:
The sorting function attempts to sort action parameters by either the
position
attribute (if present) or thename
. In some cases,position
is an integer whilename
is a string, leading to a type comparison error in Python 3.Fix:
The
_get_parameter_sort_value
method has been updated to:position
attribute to a string (if it exists) for consistent sorting.name
whenposition
is not available.Fixes #5130