Merged
Conversation
e4f2b1f to
4016074
Compare
Contributor
|
brutal but I agree, best approach for this Briefly investigated how other large libraries do this, they do have diff (but similar) approaches to dealing with init and I agree that Pauls approach here seems best |
leshy
reviewed
Mar 14, 2026
Contributor
There was a problem hiding this comment.
I assume these changes are related to not requiring (even empty) init files for mypy etc?
edit
yes!
81a43ae to
cac9a21
Compare
leshy
approved these changes
Mar 14, 2026
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.
Problem
We have a lot of
__init__.pyfiles which aggregate imports. This causes us to waste time importing things we don't need. Jeff has merged a solution to this ( Import Fix & Optimize: G1 without ROS, lazy imports, Fix bad dir naming, DIM-457, DIM-458, DIM-460, DIM-461 #1221 ), but I don't see why we need to bother re-exporting things to begin with. It's so much easier to import from the source.What bugs me is that when we re-export, we end up with two (or more) paths from which we can import the same thing. The codebase has this a lot.
You always have to double check what you're importing. This occurs when a re-export shadows a module with a function within it. For example imagine you have def foo in
dimos/core/foo.py. You usefoo(…)in your code and you have to import it. Which import do you add?from dimos.core import fooorfrom dimos.core.foo import foo. The second is always reliable. But the first depends on whetherdimos/core/__init__.pyre-exports def foo. If it does not, thenfrom dimos.core import foois still valid, but it's not the function, it's the module. Allowing re-exports leads to uncertainty.If the worry is that removing them creates long imports for users, then there is a solution for this. We can create a single file of lazy imports at the root defining our entire public API. But internally, we should just import things from where they are defined.
Closes DIM-534
Solution
__init__.pyfiles.__init__.pyfiles aren't added again.Breaking Changes
How to Test
...
Contributor License Agreement