Skip to content

Cannot import local type stub (.pyi) #11414

@smiRaphi

Description

@smiRaphi

Describe the bug
I'm trying to import a local typing stub (lib.cryptox="lib/cryptox.pyi")
But it's telling me "Import lib.cryptox could not be resolved from source" (I also tried just ".cryptox" but same thing)
When I added the whole lib directory as "include" in pyrightconfig.json, I was able to import it via from cryptox import MT19937

Code or Screenshots
lib/cryptox.pyi:

from typing import Self

class MT19937:
    STATE_LENGTH:int # readonly
    STATE_M:int # readonly
    MATRIX_A:int # readonly
    TEMPERING_MASK_B:int
    TEMPERING_MASK_C:int

    def __init__(self,seed:int=None) -> None: ...
    def init(self,seed:int) -> Self: ...
    def s_rand(self,seed:int) -> None: ...
    def rand(self) -> int: ...

lib/crypto.py:

from lib.cryptox import MT19937

VS Code extension or command-line
VS Code extension

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions