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

Make SemanticParent explicitly a MutableMapping[str, Semantic] #588

Open
liamhuber opened this issue Feb 11, 2025 · 2 comments
Open

Make SemanticParent explicitly a MutableMapping[str, Semantic] #588

liamhuber opened this issue Feb 11, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@liamhuber
Copy link
Member

Right now we can for node in some_composite: and iterate over the child node instances, and quickly look at some_composite.child_labels to see all the keys. It would be much clearer to just explicitly follow the mutable mapping pattern and use for node in some_composite.values() and some_composite.keys().

I haven't thought deeply about the side effects this might have, but naively I expect it to work fine. It is a bunch of leg work to go through and modify all the existing invokations of for-loops, since they'd suddenly be looping over keys rather than values, but while nit-picky these changes should be straightforward.

@liamhuber liamhuber added the enhancement New feature or request label Feb 11, 2025
@XzzX
Copy link
Contributor

XzzX commented Feb 12, 2025

I 💯 agree. I just did not dare to mention it.

@liamhuber
Copy link
Member Author

No, of course it should be so; saying so is fine as long as you don't expect me to act on it with any particular timeline 😝

collections.abc compliance was not on my radar back when I was writing this, but I agree it's a much nicer way to do things. I'm sure there are other places we can exploit it, but this is the one that has been bugging me most. I only got around to raising an issue for it when it came up online Sam's PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants