Skip to content

Fix call to sorted by providing key to sort on. #12275

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

Merged
merged 1 commit into from
Jan 21, 2020
Merged

Fix call to sorted by providing key to sort on. #12275

merged 1 commit into from
Jan 21, 2020

Conversation

micque01
Copy link
Contributor

Summary of changes

This is a fix to the tools for running under Python 3.

This call to sorted does nothing in Python 2, as there is no way to sort a list of Exceptions without providing a key. It will simply return the evaluated generator as a list.

In Python 3 this call fails with TypeError : '<' not supported between instances of 'ValidationError' and 'ValidationError', as there is no comparison implemented for the jsonschema.exceptions.ValidationError Exception.

This is fixed by providing the key str, which sorts by the string representation of
the Exception.

Documentation

None


Pull request type

[X] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[] Feature update (New feature / Functionality change / New API)
[] Major update (Breaking change E.g. Return code change / API behaviour change)

Test results

[] No Tests required for this change (E.g docs only update)
[] Covered by existing mbed-os tests (Greentea or Unittest)
[] Tests / results supplied as part of this PR

Reviewers

@madchutney @mark-edgeworth


This call to sorted does nothing in Python 2, as there is no way to sort a list
of Exceptions without providing a key.

In Python 3 this call fails with an error as there is no comparison implemented
for the jsonschema.exceptions.ValidationError Exception.

This is fixed by providing the key str, which sorts by the str representation of
the Exception.
@ciarmcom ciarmcom requested review from a team January 17, 2020 14:00
@ciarmcom
Copy link
Member

@micque01, thank you for your changes.
@ARMmbed/mbed-os-tools @ARMmbed/mbed-os-maintainers please review.

@adbridge
Copy link
Contributor

CI started

@mbed-ci
Copy link

mbed-ci commented Jan 20, 2020

Test run: SUCCESS

Summary: 11 of 11 test jobs passed
Build number : 2
Build artifacts

@adbridge adbridge merged commit 2757e9a into ARMmbed:master Jan 21, 2020
@adbridge adbridge added release-version: 6.0.0-alpha-2 Second pre-release version of 6.0.0 and removed ready for merge labels Jan 21, 2020
@mergify
Copy link

mergify bot commented Jan 21, 2020

This PR does not contain release version label after merging.

@micque01 micque01 deleted the tools-fix-call-to-sorted branch January 22, 2020 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-version: 6.0.0-alpha-2 Second pre-release version of 6.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants