Skip to content

pyright uses pandas for type hinting instead of pandas-stubs #1132

@olli-hw

Description

@olli-hw

Describe the bug
I am using pyright through mason.nvim on Neovim. On pandas/pandas-stubs version <=2.0.3.230814 the stubs are used correctly. However, on version >=2.1.1.230928, the pandas definitions are used instead.

To Reproduce

  1. Provide a minimal runnable pandas example that is not properly checked by the stubs.
  2. Indicate which type checker you are using (mypy or pyright).
  3. Show the error message received from that type checker while checking your example.

Please complete the following information:

  • OS: Windows 11 Pro
  • OS Version Version 10.0.22631 Build 22631
  • python version 3.10.2
  • version of type checker
  • version of installed pandas-stubs 2.1.1.230928, 2.2.3.241126

Additional context
microsoft/pyright#3540
I followed the repro steps in the above ticket to test. Version 1.4.2 which is specified there works fine. Then I incrementally upgrade pandas/pandas-stubs. Once I get to version 2.1.1.230928 (the next version available after 2.0.3.230814), stubs are no longer used and pandas definitions are used instead.

The way I am testing this is that I import DataFrame into a python script, then use LSP to goto definition. I am expecting it to go to the stub definition, which it does when it works. When it stops working (version 2.1.1.230928 and up), it goes to the pandas definition.

pyright LSP server configuration schema:

        → pyright.disableLanguageServices              default: false
        → pyright.disableOrganizeImports               default: false
        → pyright.disableTaggedHints                   default: false
        → python.analysis.autoImportCompletions        default: true
        → python.analysis.autoSearchPaths              default: true
        → python.analysis.diagnosticMode               default: "openFilesOnly"
        → python.analysis.diagnosticSeverityOverrides
        → python.analysis.exclude                      default: []
        → python.analysis.extraPaths                   default: []
        → python.analysis.ignore                       default: []
        → python.analysis.include                      default: []
        → python.analysis.logLevel                     default: "Information"
        → python.analysis.stubPath                     default: "typings"
        → python.analysis.typeCheckingMode             default: "standard"
        → python.analysis.typeshedPaths                default: []
        → python.analysis.useLibraryCodeForTypes       default: true
        → python.pythonPath                            default: "python"
        → python.venvPath                              default: ""

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