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

Pylance function return type inlay hints do not work on closures

Open randori-ddejohn opened this issue 1 year ago • 2 comments

Environment data

  • Pylance version: v2024.7.1
  • OS and version: Windows 11
  • Python version (& distribution if applicable, e.g. Anaconda): clean install of Python 3.11

Code Snippet

def simple_closure(a: int):
    def doubler():
        return a * 2
    return doubler

Repro Steps

  1. configure Pylance extension in settings.json with "python.analysis.inlayHints.functionReturnTypes": true,
  2. open a new file
  3. paste the code
  4. double click the inlay type hint

Expected behavior

The type hint should import Callable and fill in the type hint

Actual behavior

As you can see, double clicking to insert the type hint adds it as a comment. Repeatedly double-clicking keeps appending a new comment onto the end of the line.

https://github.com/user-attachments/assets/63022b26-6d37-4e6c-aa59-f2e5aff977e3

Logs

No logs to show.

randori-ddejohn avatar Jan 02 '25 19:01 randori-ddejohn

thanks for the report. Looking into it.

bschnurr avatar Jan 13 '25 17:01 bschnurr

Any updates on this?

randori-ddejohn avatar Jul 15 '25 17:07 randori-ddejohn