Repository navigation
Conversation
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.
Adds the mypy plugin of nuke-di to Mypy plugins, in alphabetical order.
nuke-di is dependency injection driven by type hints: a client asks for its dependencies in its type-hinted
__init__, a function in its signature. The plugin,nuke_di.mypy, turns the runtime check of the dependency tree into a static one:resolve(),inject(),@joband@workerit walks the__init__of every client the call would build, as the container does, and reports what the container would raise, with the same message and the path to it: an argument that is not a client, a missing type hint, a circular dependency. Where the container stops at the first error, the plugin reports them all.inject()is typed as the function without its injected arguments (def (user_id: int) -> Coroutine[Any, Any, str]instead ofCallable[..., ...]).Works with mypy 1.13+, with and without the cache. Docs: Checking the tree with mypy.
Disclosure: I am the author.