Update NbdevLookup to support import aliases and improve docstrings #1471
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.
This PR adds support to us NbdevLookup on import aliases such as
import numpy as np
. For example, you can now do the following:The way this works, is that an alias mapping is created in NbdevLookup:
This maps the alias to its true name. We then use this in the get item function when necessary:
However, it required removing
lru_cache(None)
as a class level decorator since the dictionary for the namespace used to create the aliases of the imports and their true symbol names is not hashable. A work around would be to not do it on the class level and just decorate the functions that need it, but wanted to open up the PR to start a discussion on this as a direction before investing more time into it.