Skip to content

Non-consistent type-hinting for signature of func with variable amount of dynamically added params #9472

Discussion options

You must be logged in to vote

When a type checker evaluates the type of a call expression, it uses the signature of the target call. It does not use the implementation of the target call in this circumstance. Often (e.g. in the case of type stubs), the implementation is not even provided to a type checker.

If you omit the return type annotation for a function, pyright will attempt to infer its return type based on the implementation, but that inferred return type is then used to define the signature.

If the implementation of a function is provided, a type checker will check the code within that function. However, the body of a function isn't used to evaluate calls to that function. That's why I stripped out the implem…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@vladislav-krastev
Comment options

@erictraut
Comment options

@vladislav-krastev
Comment options

@erictraut
Comment options

Answer selected by vladislav-krastev
@vladislav-krastev
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants