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

Preserve order of entries in expand method #348

Merged
merged 1 commit into from
Dec 11, 2023

Conversation

pvandyken
Copy link
Contributor

.expand() in all three Expandables was using set() to deduplicate paths following expansion. This was altering the order of the paths, preventing predicatable expansion

This fix uses dict.fromkeys to deduplicate while preserving order

.expand() in all three Expandables was using `set()` to deduplicate
paths following expansion. This was altering the order of the paths,
preventing predicatable expansion

This fix uses `dict.fromkeys` to deduplicate while preserving order

Resolves khanlab#346
@pvandyken pvandyken added the bug Something isn't working label Dec 10, 2023
@github-actions github-actions bot requested review from akhanf and kaitj December 10, 2023 01:25
@pvandyken pvandyken linked an issue Dec 10, 2023 that may be closed by this pull request
@pvandyken pvandyken requested a review from myousif9 December 10, 2023 01:26
Copy link
Contributor

@kaitj kaitj left a comment

Choose a reason for hiding this comment

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

Looks good to me - left one comment that does not need any action here.

@@ -2,7 +2,7 @@
This type stub file was generated by pyright.
"""

"""Miscellaneous layout-related utilities."""
from typing import Sequence
Copy link
Contributor

Choose a reason for hiding this comment

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

More of a comment here given this was generated by pyright, but we should look to switch use of abstract base classes in the code base to import from collections.abc. I think a number of these are deprecated from the typing module as of py3.9+.

Related - I came across this a while back, which may be helpful in upgrading syntax, etc: https://github.com/asottile/pyupgrade

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ruff handles these upgrades, so I've been letting it handle it. So may plan was to wait until we drop py38 next year, then ruff should inform us of all these deprecations.

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool - I didn't know that. Just took a quick look at the ruff source code and it looks like they're using pyupgrade under the hood too.

@pvandyken pvandyken merged commit dd2ce68 into khanlab:main Dec 11, 2023
28 checks passed
@pvandyken pvandyken deleted the fix/expand-ordering branch December 11, 2023 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BidsComponent.expand() fails to preserve order
2 participants