Sample Header Ad - 728x90

Pyright in VSCodium is confused about type-checking a function assigned to a variable

0 votes
0 answers
47 views
I'm using VSCodium with the Pyright plugin for Python type checking. I am puzzled why Pyright is not recognizing a variable as type function, when the code works as expected, and entering this code in the Python REPL I can verify action is a function, has a __call__ method, etc.
def pass2() -> None:
    pass

action_set: dict[str, function] = {'pass2': pass2}
action: function = action_set["pass2"]

action()
VSCodium displays this error under action() in line 7: 'Object of type "function" is not callable - Attribute "__call__" is unknown'. But for action on line 5 it shows '(variable) action: function'.
Asked by M Hill (1 rep)
May 20, 2025, 09:22 PM
Last activity: May 20, 2025, 09:39 PM