support for __all__ filtering with from ... import *#10518
Closed
jbrelwof wants to merge 1 commit intoadafruit:mainfrom
Closed
support for __all__ filtering with from ... import *#10518jbrelwof wants to merge 1 commit intoadafruit:mainfrom
__all__ filtering with from ... import *#10518jbrelwof wants to merge 1 commit intoadafruit:mainfrom
Conversation
Collaborator
|
Since this is fixed by micropython#17331, we could wait for that. We will be merging from MicroPython when V1.26 comes out. |
Collaborator
|
I'm going to close this since it will be fixed by some upstream code when we merge v1.26. |
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.
__all__withfrom ... import *#10516.Circuitpython does not support filtering
from someModule import *when someModule contains__all__ = ['symbol1', 'symbol2', ...]. This results in importing more symbols than intended, which can cause a little wasted memory (entries in the globals() in the scope containingfrom someModule import *) and differs from CPython in ways that can introduce subtle bugs (primarily through unexpected replacement of existing symbols).This includes an enhanced mp_import_all(...) in py/runtime.c to support
from ... import *filtering when__all__ = [...]is present.I have basic tests (which it passes) for the following:
__all__are not imported)__all__will throw TypeError__all__(i.e.__all__ = ['hello','world']where world is undefined) will throw AttributeErrorbut I'm not sure where/how to add them so they become part of the CircuitPython CI testing pipeline
I also have a few things that I got "working" through trial and error which might have more efficient / recognizable patterns available. For example:
__all____all__for lookup key