Skip to content

Is a missing __init__.pyi in a bundled stub cause a false positive in Pylance? #389

@hunterhogan

Description

@hunterhogan

Is it possible that because sympy-stubs does not have 'combinatorics/init.pyi', Pylance could not find the logical path sympy.combinatorics.Permutation?

In VSCode-insiders, Pylance was reporting Permutation and PermutationGroup could not be found with this statement:

from sympy.combinatorics import Permutation, PermutationGroup

I was three-times confused because 1) the SymPy documentation uses that logical path, 2) the installed package seemed to be re-exporting from that logical path (see __init__.py), and 3) my personally generated stubs for SymPy re-export on that path (see here; I didn't find sympy-stubs in this repo until today). So I used the following statements, which worked fine.

from sympy.combinatorics.perm_groups import PermutationGroup
from sympy.combinatorics.permutations import Permutation

But I was still confused, so I started poking around the stub files and the installed package files--while using VSCode to navigate and open the files. It seems that I somehow caused Pylance to stop using "%USERPROFILE%.vscode-insiders\extensions\ms-python.vscode-pylance-2025.8.100\dist\bundled\stubs\sympy-stubs\combinatorics..." and start using my stubs. Now, from sympy.combinatorics import Permutation works as expected.

I think that adds up to Pylance reporting it couldn't find from sympy.combinatorics import Permutation because the bundled stubs don't have __init__.pyi to re-export those symbols.

BUT, I could be completely wrong. There are a lot of moving parts in this system, and my knowledge is minuscule.

I know y'all aren't Pylance, but there is a non-zero chance this log could be useful to you.

Python Language Server.log

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions