pylance-release icon indicating copy to clipboard operation
pylance-release copied to clipboard

Pylance incorrectly reports no arguments expected to pandas context manager

Open diepala opened this issue 2 years ago • 0 comments

Environment data

  • Language Server version: 2022.6.20
  • OS and version: Ubuntu 22.04
  • Python version (& distribution if applicable, e.g. Anaconda): 3.10.4

Code Snippet

import pandas as pd

with pd.option_context('display.max_rows', 10):
        pass

Repro Steps

  1. In VSCode working diretory, place a file pyrightconfig.json with the following content:
{
    "typeCheckingMode": "basic",
}
  1. Paste the python snippet in a new python file.

Expected behavior

No error should occur.

Actual behavior

Pylance reports 2 errors:

  1. Expected no arguments to "option_context" constructor.
  2. Object of type "option_context" cannot be used with "with" because it does not implement enter.

Neither of this errors should occur, as the source codes for this context manager is correct. Also, when running pyright from the command line, these errors don't appear.

diepala avatar Jun 21 '22 21:06 diepala