You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
In some situations, it is better to lazy import a module. For example, in sage this is via lazy_import('sage.rings.all', 'RDF', 'my_RDF') in place of the standard import ... from ... as ... syntax, see https://doc.sagemath.org/html/en/reference/misc/sage/misc/lazy_import.html.
Pyright currently does not pick up these imports and warns that the class is unknown (my_RDF in the above example).
Describe the solution you'd like
Properly recognize lazy imports.
The text was updated successfully, but these errors were encountered:
There's currently no support in the Python standard for expressing lazy imports. Pyright follows the Python standard and does not contain any special knowledge of third-party library behaviors like the one in sage.
As a workaround, you could use lazy imports in conjunction with traditional imports, but place the traditional imports within a if TYPE_CHECKING: statement. That way, it won't execute at runtime, but the type checker will know about import for type checking purposes.
Is your feature request related to a problem? Please describe.
In some situations, it is better to lazy import a module. For example, in sage this is via
lazy_import('sage.rings.all', 'RDF', 'my_RDF')
in place of the standardimport ... from ... as ...
syntax, see https://doc.sagemath.org/html/en/reference/misc/sage/misc/lazy_import.html.Pyright currently does not pick up these imports and warns that the class is unknown (
my_RDF
in the above example).Describe the solution you'd like
Properly recognize lazy imports.
The text was updated successfully, but these errors were encountered: