-
Notifications
You must be signed in to change notification settings - Fork 85
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 type comparisons #1382
Fix type comparisons #1382
Conversation
linter complained about this over here galaxyproject#1381
planemo/workflow_lint.py
Outdated
@@ -191,12 +191,12 @@ def _lint_best_practices(path: str, lint_context: WorkflowLintContext) -> None: | |||
""" | |||
|
|||
def check_json_for_untyped_params(j): | |||
values = j if type(j) == list else j.values() | |||
values = j if isinstance(j, list) else j.values() |
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 you check this is a dict instance instead ? that should be less narrow. Also the check in line 196 isn't really how you'd do this
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 you check this is a dict instance instead ?
So is TYPE
everywhere?
Also the check in line 196 isn't really how you'd do this
Also with is
?
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.
No, type is type is the most narrow of them all which will not work for any subclasses. .values()
will only work for objects that satisfy Mapping, while any j that is Iterable will work. So check for the specific instance where you need to call .values()
first isinstance(j, Mapping)
and don't worry about the other types that will all be fine.
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.
Thank you!
linter complained about this over here #1381
Not sure if
isinstance
oris
is correct?