-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
as designedNot a bug, working as intendedNot a bug, working as intended
Description
Describe the bug
The attached code used to typecheck with 1.1.295 and earlier. I don't see anything obviously wrong with it.
The error seems to be both depending on defining the __name__
attribute and the use of functools.wraps
To Reproduce
Typecheck the following code with 1.1.296 results in
No configuration file found.
No pyproject.toml file found.
stubPath C:\Users\Jens-work\typings is not a valid directory.
Assuming Python platform Windows
Searching for source files
Found 1 source file
pyright 1.1.296
C:\Users\Jens-work\typecheck_callable_protocol.py
C:\Users\Jens-work\typecheck_callable_protocol.py:21:12 - error: Expression of type "_Wrapped[(input: int, optional_input: bool = True), None, (input: int, optional_input: bool = True), None]" cannot be assigned to return type "FunctionToWrap"
"_Wrapped[(input: int, optional_input: bool = True), None, (input: int, optional_input: bool = True), None]" is incompatible with protocol "FunctionToWrap"
"__name__" is not present (reportGeneralTypeIssues)
1 error, 0 warnings, 0 informations
Completed in 0.83sec
Expected behavior
Type check without error.
Screenshots or Code
from functools import wraps
from typing import Protocol
class FunctionToWrap(Protocol):
def __call__(self, input: int, optional_input: bool = True) -> None:
...
@property
def __name__(self) -> str:
...
WRAPPED_FUNCS: dict[str, FunctionToWrap] = {}
def upgrader(func: FunctionToWrap) -> FunctionToWrap:
WRAPPED_FUNCS[func.__name__] = func
@wraps(func)
def call_wrapped_func(input: int, optional_input: bool = True) -> None:
...
return call_wrapped_func
VS Code extension or command-line
Command-line 1.1.295 and 1.1.296 installed from npm
Additional context
Windows 10/11 python 3.8 and 3.11
Metadata
Metadata
Assignees
Labels
as designedNot a bug, working as intendedNot a bug, working as intended