Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Intellisense fails with function decorators #2119

@tbennun

Description

@tbennun

Environment data

  • Language Server version: 0.5.51.0
  • OS and version: Windows 10 Build 20221
  • Python version (& distribution if applicable, e.g. Anaconda): Anaconda with Python 3.7.7

Expected behaviour

When using function decorators with a return value type hint, the decorated function should assume the type of the return value.

Actual behaviour

Instead, the language server thinks that the function is of type function, or some unknown type (see image below).

Code snippet available below.

Logs

[Info  - 10:15:37 PM] Analysis cache path: C:\Users\**\AppData\Local\Microsoft\Python Language Server
[Info  - 10:15:37 PM] Microsoft Python Language Server version 0.5.51.0
[Info  - 10:15:37 PM] Workspace root: c:\Users\**\Desktop\**
[Info  - 10:15:37 PM] GetCurrentSearchPaths C:\Users\**\anaconda3\envs\**\python.exe 
[Info  - 10:15:37 PM] Interpreter search paths:
[Info  - 10:15:37 PM]     c:\users\**\anaconda3\envs\**\dlls
[Info  - 10:15:37 PM]     c:\users\**\anaconda3\envs\**\lib
[Info  - 10:15:37 PM]     c:\users\**\anaconda3\envs\**
[Info  - 10:15:37 PM]     c:\users\**\anaconda3\envs\**\lib\site-packages
[Info  - 10:15:37 PM] User search paths:
[Info  - 10:15:42 PM] Initializing for C:\Users\**\anaconda3\envs\**\python.exe
[Info  - 10:15:42 PM] Analysis caching mode: None.
[Info  - 10:23:25 PM] Analysis caching mode: None.
[Info  - 10:26:11 PM] Analysis caching mode: None.
Analysis of Untitled-1 (User) on depth 0 completed in 0.16 ms.
Analysis complete: 1 modules in 0.29 ms.
Analysis version 68 of 1 entries has been completed in 0.21 ms.
Analysis of Untitled-1 (User) queued. Dependencies: 
Analysis version 69 of 1 entries has started.
Analysis of Untitled-1 (User) on depth 0 completed in 0.16 ms.
Analysis complete: 1 modules in 0.27 ms.
Analysis version 69 of 1 entries has been completed in 0.2 ms.
Code Action in file:///c:/Users/**/Desktop/**/Untitled-1.py at (13, 3) - (13, 3)
Analysis of Untitled-1 (User) queued. Dependencies: 
Analysis version 70 of 1 entries has started.
Analysis of Untitled-1 (User) on depth 0 completed in 0.14 ms.
Analysis complete: 1 modules in 0.26 ms.
Analysis version 70 of 1 entries has been completed in 0.2 ms.
Code Action in file:///c:/Users/**/Desktop/**/Untitled-1.py at (13, 13) - (13, 13)
Completions in file:///c:/Users/**/Desktop/**/Untitled-1.py at (13, 14)
Analysis of Untitled-1 (User) queued. Dependencies: 
Analysis version 71 of 1 entries has started.
Analysis of Untitled-1 (User) on depth 0 completed in 0.17 ms.
Analysis complete: 1 modules in 0.31 ms.
Analysis version 71 of 1 entries has been completed in 0.24 ms.
Code Action in file:///c:/Users/**/Desktop/**/Untitled-1.py at (13, 14) - (13, 14)
Code Action in file:///c:/Users/**/Desktop/**/Untitled-1.py at (13, 14) - (13, 14)

Code Snippet / Additional lnformation

The following code reproduces the issue:

class Example(object):
    def do_something(self):
        pass


def decorator(func) -> Example:
    return Example()


@decorator
def some_function():
    pass

# Then type "some_function." and ctrl-space

This is the box that pops up:
image

If the line some_function: Example is explicitly given, Intellisense suggestions change correctly to:
image

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