microsoft / pylance-release

Documentation and issues for Pylance
Creative Commons Attribution 4.0 International
1.71k stars 765 forks source link

Pylance autocompletes decorator of the function instead of function itself in inheritance #6450

Open mmzeynalli opened 3 weeks ago

mmzeynalli commented 3 weeks ago

Environment data

Code Snippet

class ApiResponse(BaseModel, Generic[ResponseType]):
    body: ResponseType

class SyncApiRequest:
    def __call__(self, *args: Any, **kwds: Any):
        pass

def send_request(func: Callable[..., ApiResponse]):
    def wrapper(self, *args, **kwargs) -> ApiResponse:
        func(self, *args, **kwargs)
        return self.__call__()

    return wrapper

class Request(SyncApiRequest):
    @send_request
    def save_card(self) -> ApiResponse:
        self.path = '/api/1/card-registration'
        self.verb = 'POST'

class AsyncRequest(Request):
    async def save_card(self, **extra) -> ApiResponse[EPointRedirectUrlResponseSchema]:
        return await super().save_card(**extra)

Repro Steps

  1. In AsyncRequest class, try to write save_, and autocomplete with Pylance.

Expected behavior

It autocompletes as in code above

Actual behavior

image image

It does it for decorator, instead of save_card function.

Logs

2024-09-25 14:04:00.517 [info] (28636) [FG] parsing: file:///c%3A/Users/mirad/Documents/Projects/epoint/integrify/epoint/asyncio.py (1ms)
2024-09-25 14:04:00.517 [info] (28636) [FG] binding: file:///c%3A/Users/mirad/Documents/Projects/epoint/integrify/epoint/asyncio.py (1ms)
2024-09-25 14:04:00.566 [info] [Info  - 2:04:00 PM] (28636) Heap stats: total_memory_size=48771MB, total_free_size=33713MB, total_heap_size=113MB, used_heap_size=102MB, cross_worker_used_heap_size=102MB, total_physical_size=113MB, total_available_size=3990MB, heap_size_limit=4096MB
2024-09-25 14:04:00.767 [info] (28636) [BG(1)] analyzing: file:///c%3A/Users/mirad/Documents/Projects/epoint/integrify/epoint/asyncio.py ...
2024-09-25 14:04:00.767 [info] (28636) [BG(1)]   parsing: file:///c%3A/Users/mirad/Documents/Projects/epoint/integrify/epoint/asyncio.py (1ms)
2024-09-25 14:04:00.767 [info] (28636) [BG(1)]   binding: file:///c%3A/Users/mirad/Documents/Projects/epoint/integrify/epoint/asyncio.py (0ms)
2024-09-25 14:04:00.812 [info] (28636) [BG(1)]   checking: file:///c%3A/Users/mirad/Documents/Projects/epoint/integrify/epoint/asyncio.py (45ms)
2024-09-25 14:04:00.812 [info] [Info  - 2:04:00 PM] (28636) Heap stats: total_memory_size=48771MB, total_free_size=33706MB, total_heap_size=100MB, used_heap_size=91MB, cross_worker_used_heap_size=91MB, total_physical_size=100MB, total_available_size=4001MB, heap_size_limit=4096MB
2024-09-25 14:04:00.812 [info] (28636) [BG(1)] analyzing: file:///c%3A/Users/mirad/Documents/Projects/epoint/integrify/epoint/asyncio.py (46ms)
2024-09-25 14:04:00.813 [info] (28636) [BG(1)] analyzing: untitled:Untitled-1 ...
2024-09-25 14:04:00.813 [info] (28636) [BG(1)]   checking: untitled:Untitled-1 (1ms)
2024-09-25 14:04:00.813 [info] (28636) [BG(1)] analyzing: untitled:Untitled-1 (1ms)
2024-09-25 14:04:00.815 [info] (28636) [BG(1)] SemanticTokens delta previousResultId:1727265801511 at file:///c%3A/Users/mirad/Documents/Projects/epoint/integrify/epoint/asyncio.py (0ms)
2024-09-25 14:04:00.815 [info] (28636) [BG(1)] indexing: file:///c%3A/Users/mirad/Documents/Projects/epoint/integrify/epoint/asyncio.py [found 3] (0ms)
2024-09-25 14:04:00.815 [info] (28636) Indexing Done: file:///c%3A/Users/mirad/Documents/Projects/epoint/integrify/epoint/asyncio.py
2024-09-25 14:04:00.820 [info] (28636) [BG(1)] SemanticTokens delta previousResultId:1727265840813 at file:///c%3A/Users/mirad/Documents/Projects/epoint/integrify/epoint/asyncio.py (0ms)
2024-09-25 14:04:01.754 [info] (28636) [FG] parsing: file:///c%3A/Users/mirad/Documents/Projects/epoint/integrify/epoint/asyncio.py (1ms)
2024-09-25 14:04:01.755 [info] (28636) [FG] binding: file:///c%3A/Users/mirad/Documents/Projects/epoint/integrify/epoint/asyncio.py (0ms)
2024-09-25 14:04:01.800 [info] (28636) [BG(1)] analyzing: file:///c%3A/Users/mirad/Documents/Projects/epoint/integrify/epoint/asyncio.py ...
2024-09-25 14:04:01.800 [info] (28636) [BG(1)]   parsing: file:///c%3A/Users/mirad/Documents/Projects/epoint/integrify/epoint/asyncio.py (0ms)
2024-09-25 14:04:01.800 [info] (28636) [BG(1)]   binding: file:///c%3A/Users/mirad/Documents/Projects/epoint/integrify/epoint/asyncio.py (1ms)
2024-09-25 14:04:01.842 [info] (28636) [BG(1)]   checking: file:///c%3A/Users/mirad/Documents/Projects/epoint/integrify/epoint/asyncio.py (42ms)
2024-09-25 14:04:01.843 [info] [Info  - 2:04:01 PM] (28636) Heap stats: total_memory_size=48771MB, total_free_size=33705MB, total_heap_size=108MB, used_heap_size=95MB, cross_worker_used_heap_size=95MB, total_physical_size=108MB, total_available_size=3998MB, heap_size_limit=4096MB
2024-09-25 14:04:01.843 [info] (28636) [BG(1)] analyzing: file:///c%3A/Users/mirad/Documents/Projects/epoint/integrify/epoint/asyncio.py (43ms)
2024-09-25 14:04:01.844 [info] (28636) [BG(1)] analyzing: untitled:Untitled-1 ...
2024-09-25 14:04:01.844 [info] (28636) [BG(1)]   checking: untitled:Untitled-1 (1ms)
2024-09-25 14:04:01.844 [info] (28636) [BG(1)] analyzing: untitled:Untitled-1 (1ms)
2024-09-25 14:04:01.845 [info] (28636) [BG(1)] indexing: file:///c%3A/Users/mirad/Documents/Projects/epoint/integrify/epoint/asyncio.py [found 3] (0ms)
2024-09-25 14:04:01.845 [info] (28636) Indexing Done: file:///c%3A/Users/mirad/Documents/Projects/epoint/integrify/epoint/asyncio.py
2024-09-25 14:04:01.848 [info] (28636) [BG(1)] SemanticTokens delta previousResultId:1727265840813 at file:///c%3A/Users/mirad/Documents/Projects/epoint/integrify/epoint/asyncio.py (1ms)
2024-09-25 14:04:03.710 [info] (28636) [FG] parsing: file:///c%3A/Users/mirad/Documents/Projects/epoint/integrify/epoint/asyncio.py (1ms)
2024-09-25 14:04:03.711 [info] (28636) [FG] binding: file:///c%3A/Users/mirad/Documents/Projects/epoint/integrify/epoint/asyncio.py (0ms)
2024-09-25 14:04:03.757 [info] (28636) [BG(1)] analyzing: file:///c%3A/Users/mirad/Documents/Projects/epoint/integrify/epoint/asyncio.py ...
2024-09-25 14:04:03.758 [info] (28636) [BG(1)]   parsing: file:///c%3A/Users/mirad/Documents/Projects/epoint/integrify/epoint/asyncio.py (2ms)
2024-09-25 14:04:03.758 [info] (28636) [BG(1)]   binding: file:///c%3A/Users/mirad/Documents/Projects/epoint/integrify/epoint/asyncio.py (0ms)
2024-09-25 14:04:03.813 [info] (28636) [BG(1)]   checking: file:///c%3A/Users/mirad/Documents/Projects/epoint/integrify/epoint/asyncio.py (55ms)
2024-09-25 14:04:03.813 [info] [Info  - 2:04:03 PM] (28636) Heap stats: total_memory_size=48771MB, total_free_size=33713MB, total_heap_size=113MB, used_heap_size=82MB, cross_worker_used_heap_size=82MB, total_physical_size=113MB, total_available_size=4010MB, heap_size_limit=4096MB
2024-09-25 14:04:03.813 [info] (28636) [BG(1)] analyzing: file:///c%3A/Users/mirad/Documents/Projects/epoint/integrify/epoint/asyncio.py (57ms)
2024-09-25 14:04:03.813 [info] (28636) [BG(1)] SemanticTokens delta previousResultId:1727265841847 at file:///c%3A/Users/mirad/Documents/Projects/epoint/integrify/epoint/asyncio.py (1ms)
2024-09-25 14:04:03.815 [info] (28636) [BG(1)] analyzing: untitled:Untitled-1 ...
2024-09-25 14:04:03.815 [info] (28636) [BG(1)]   checking: untitled:Untitled-1 (1ms)
2024-09-25 14:04:03.816 [info] (28636) [BG(1)] analyzing: untitled:Untitled-1 (1ms)
2024-09-25 14:04:03.816 [info] (28636) [BG(1)] indexing: file:///c%3A/Users/mirad/Documents/Projects/epoint/integrify/epoint/asyncio.py [found 3] (0ms)
2024-09-25 14:04:03.816 [info] (28636) Indexing Done: file:///c%3A/Users/mirad/Documents/Projects/epoint/integrify/epoint/asyncio.py
2024-09-25 14:04:03.817 [info] (28636) [BG(1)] SemanticTokens delta previousResultId:1727265843812 at file:///c%3A/Users/mirad/Documents/Projects/epoint/integrify/epoint/asyncio.py (0ms)
2024-09-25 14:04:03.847 [info] [Info  - 2:04:03 PM] (28636) SourceFile: Received fs event 'change' for path 'c:\Users\mirad\Documents\Projects\epoint\integrify\epoint\asyncio.py'
2024-09-25 14:04:04.330 [info] (28636) [BG(1)] indexing: file:///c%3A/Users/mirad/Documents/Projects/epoint/integrify/epoint/asyncio.py [found 3] (0ms)
2024-09-25 14:04:04.331 [info] (28636) Indexing Done: file:///c%3A/Users/mirad/Documents/Projects/epoint/integrify/epoint/asyncio.py
KacieKK commented 3 weeks ago

Thanks for reporting. I can repro.