Skip to content

Does Pyright support non-conventional import statements which involves a function (e.g. import_python("foo.bar", "ExampleFunc")) #9396

Answered by erictraut
dluo asked this question in Q&A
Discussion options

You must be logged in to vote

Pyright is a standards-compliant Python type checker. What you're suggesting would be a non-standard extension.

Pyright has no hard-coded knowledge of third-party libraries. All of its knowledge about the semantics of third-party libraries comes from the type annotations provided in the library code or in stub files. There's currently no way in the Python type system to indicate that a library is providing custom import behavior.

If you want to explore something like this, you could propose it in the Python typing forum, but my guess is that there won't be much appetite within the typing community to support non-standard mechanisms like this.

Pyright is open-sourced, so one option is to c…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@dluo
Comment options

Answer selected by dluo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants