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

change: Follow imports when loading #347

Open
pawamoy opened this issue Dec 26, 2024 · 0 comments
Open

change: Follow imports when loading #347

pawamoy opened this issue Dec 26, 2024 · 0 comments
Assignees
Labels
refactor Change suggestion, not a bug nor a feature.

Comments

@pawamoy
Copy link
Member

pawamoy commented Dec 26, 2024

Is your change request related to a problem? Please describe.

We currently load modules in breadth-first order. That means we can rarely compute class inheritance correctly while loading (typically in extensions, which can trigger such computations). This triggers a whole class of issues, just see #340.

Describe the solution you'd like

Maybe we should try and load in the order of imports, so that inheritance can always be computed correctly, even when the whole module is not yet completely loaded.

We would not follow type-guarded imports.

We would still have to load the remaining modules that aren't imported by anyone, by iterating on the file list (current behavior).

Describe alternatives you've considered

Adding documentation warnings, but the API would still be very error prone -> users confused.

Additional context

A following import mechanism would also allow us to refactor how we "preload" modules. We could accept an "allowlist" in Griffe like resolve_external=["pydantic"], which we could use to decide to follow external imports or not.

@pawamoy pawamoy added the refactor Change suggestion, not a bug nor a feature. label Dec 26, 2024
@pawamoy pawamoy self-assigned this Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Change suggestion, not a bug nor a feature.
Projects
None yet
Development

No branches or pull requests

1 participant