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

Require aliases for submodule imports #14

Merged
merged 5 commits into from
Jan 3, 2024

Conversation

DavidCEllis
Copy link
Owner

Submodule imports without aliasess were rather messy and the general logic is much improved by their removal.

They were always limited in that any use of the main module was forced to import all submodules that could be used as there is no way for the class to know what attributes are being accessed.

eg:

from ducktools.lazyimporter import ModuleImport, LazyImporter

laz = LazyImporter([ModuleImport("importlib.util"), ModuleImport("importlib.machinery")])

laz.importlib.machinery  # importlib, importlib.util and importlib.machinery are all imported here.

Now all of the import subclasses require 'asname' or 'asnames' to be defined.

@DavidCEllis DavidCEllis merged commit 330f803 into main Jan 3, 2024
6 checks passed
@DavidCEllis DavidCEllis deleted the remove_direct_submodule_support branch January 3, 2024 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant