Skip to content

[invalid-parameter-default] on ellipsis in TYPE_CHECKING section #2534

@robsdedude

Description

@robsdedude

Summary

https://peps.python.org/pep-0484/#arbitrary-argument-lists-and-default-argument-values reads

In stubs it may be useful to declare an argument as having a default without specifying the actual default value. For example:

def foo(x: AnyStr, y: AnyStr = ...) -> AnyStr: ...

I argue, in the same vein as #339, that if TYPE_CHECKING sections are very stub-file-like. Therefore, I suggest to allow assigning ... (ellipsis) as a parameter default value. At least mypy is also fine with this.

Admittedly, mypy just allows ellipsis to be a parameter default everywhere. I'm not sure that's a good idea, really. mypy gist: https://gist.github.com/mypy-play/41532e8350478fd1a0b4fa6ee764171b

Version

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions