Open
Conversation
There was a problem hiding this comment.
No quality gates enabled for this code.
See analysis details in CodeScene
Quality Gate Profile: Custom Configuration
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.
DrPaulSharp
approved these changes
Apr 20, 2026
Contributor
DrPaulSharp
left a comment
There was a problem hiding this comment.
Thanks for the detailed review notes, I'm inclined to agree that this approach is an improvement over what we have and should be accepted on that basis, with us keeping an eye on possible improvements down the line.
|
|
||
| import importlib | ||
| import os.path | ||
| import types |
Contributor
There was a problem hiding this comment.
This line should be removed as the module is unused.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adding units.py to .gitignore can be a problem because the problem them becomes deciding when units.py gets generated.
Instead, I decided to punt on the issue by eliminating the autogenerated files entirely. Instead, the code is dynamically added to the modules at runtime. This means that the units module can never be out of sync and developers can't make changes that will be overwritten.
A couple of bits of advice for reviewing:
execis not a security concern here because it is not being called on untrusted strings. Any attacker attempting to produce a security hole here would need to be able to modify init.py or _units_base.py, which would already provide them all the privileges that they could have gained fromexec.The biggest disadvantage of this setup is that certain tools (e.g. MyPy) don't use the proper Python module loading system and do not see the members of the generated modules. I also fully concede that there might be a cleaner architecture through the use of
getattr, but that would be a significant rewrite and I thought that a smaller, incremental PR would be better at this time.Closes #199