[red-knot] ...
should be treated as a valid parameter default for any annotation in a stub file #14840
Open
Description
opened on Dec 8, 2024
The typing spec states that in stub files:
In locations where value expressions can appear, such as the right-hand side of assignment statements and function parameter defaults, type checkers should support the following expressions:
- The ellipsis literal, ..., which can stand in for any value
Following #14802, we now have a huge number of false positives when running red-knot directly over stub files, due to the fact that we don't yet implement this special case, which is very commonly utilised in stubs. E.g. here's a small portion of the errors emitted when running red-knot over typeshed:
error[invalid-parameter-default] /Users/alexw/dev/typeshed/stdlib/asyncio/base_events.pyi:118:13 Default value of type `EllipsisType | ellipsis` is not assignable to annotated parameter type `int`
error[invalid-parameter-default] /Users/alexw/dev/typeshed/stdlib/asyncio/base_events.pyi:158:13 Default value of type `EllipsisType | ellipsis` is not assignable to annotated parameter type `str`
error[invalid-parameter-default] /Users/alexw/dev/typeshed/stdlib/asyncio/base_events.pyi:159:13 Default value of type `EllipsisType | ellipsis` is not assignable to annotated parameter type `int`
error[invalid-parameter-default] /Users/alexw/dev/typeshed/stdlib/asyncio/base_events.pyi:197:13 Default value of type `EllipsisType | ellipsis` is not assignable to annotated parameter type `str`
error[invalid-parameter-default] /Users/alexw/dev/typeshed/stdlib/asyncio/base_events.pyi:198:13 Default value of type `EllipsisType | ellipsis` is not assignable to annotated parameter type `int`
error[invalid-parameter-default] /Users/alexw/dev/typeshed/stdlib/asyncio/base_events.pyi:237:13 Default value of type `EllipsisType | ellipsis` is not assignable to annotated parameter type `int`
error[invalid-parameter-default] /Users/alexw/dev/typeshed/stdlib/asyncio/base_events.pyi:239:13 Default value of type `EllipsisType | ellipsis` is not assignable to annotated parameter type `int`
error[invalid-parameter-default] /Users/alexw/dev/typeshed/stdlib/asyncio/base_events.pyi:240:13 Default value of type `EllipsisType | ellipsis` is not assignable to annotated parameter type `int`
error[invalid-parameter-default] /Users/alexw/dev/typeshed/stdlib/asyncio/base_events.pyi:258:13 Default value of type `EllipsisType | ellipsis` is not assignable to annotated parameter type `int`
error[invalid-parameter-default] /Users/alexw/dev/typeshed/stdlib/asyncio/base_events.pyi:259:13 Default value of type `EllipsisType | ellipsis` is not assignable to annotated parameter type `int`
error[invalid-parameter-default] /Users/alexw/dev/typeshed/stdlib/asyncio/base_events.pyi:260:13 Default value of type `EllipsisType | ellipsis` is not assignable to annotated parameter type `socket`
error[invalid-parameter-default] /Users/alexw/dev/typeshed/stdlib/asyncio/base_events.pyi:276:13 Default value of type `EllipsisType | ellipsis` is not assignable to annotated parameter type `int`
error[invalid-parameter-default] /Users/alexw/dev/typeshed/stdlib/asyncio/base_events.pyi:278:13 Default value of type `EllipsisType | ellipsis` is not assignable to annotated parameter type `int`
error[invalid-parameter-default] /Users/alexw/dev/typeshed/stdlib/asyncio/base_events.pyi:279:13 Default value of type `EllipsisType | ellipsis` is not assignable to annotated parameter type `int`
error[invalid-parameter-default] /Users/alexw/dev/typeshed/stdlib/asyncio/base_events.pyi:296:13 Default value of type `EllipsisType | ellipsis` is not assignable to annotated parameter type `int`
error[invalid-parameter-default] /Users/alexw/dev/typeshed/stdlib/asyncio/base_events.pyi:297:13 Default value of type `EllipsisType | ellipsis` is not assignable to annotated parameter type `int`
error[invalid-parameter-default] /Users/alexw/dev/typeshed/stdlib/asyncio/base_events.pyi:298:13 Default value of type `EllipsisType | ellipsis` is not assignable to annotated parameter type `socket`
error[invalid-parameter-default] /Users/alexw/dev/typeshed/stdlib/asyncio/base_events.pyi:313:13 Default value of type `EllipsisType | ellipsis` is not assignable to annotated parameter type `int`
error[invalid-parameter-default] /Users/alexw/dev/typeshed/stdlib/asyncio/base_events.pyi:315:13 Default value of type `EllipsisType | ellipsis` is not assignable to annotated parameter type `int`
error[invalid-parameter-default] /Users/alexw/dev/typeshed/stdlib/asyncio/base_events.pyi:316:13 Default value of type `EllipsisType | ellipsis` is not assignable to annotated parameter type `int`
error[invalid-parameter-default] /Users/alexw/dev/typeshed/stdlib/asyncio/base_events.pyi:332:13 Default value of type `EllipsisType | ellipsis` is not assignable to annotated parameter type `int`
error[invalid-parameter-default] /Users/alexw/dev/typeshed/stdlib/asyncio/base_events.pyi:333:13 Default value of type `EllipsisType | ellipsis` is not assignable to annotated parameter type `int`
error[invalid-parameter-default] /Users/alexw/dev/typeshed/stdlib/asyncio/base_events.pyi:334:13 Default value of type `EllipsisType | ellipsis` is not assignable to annotated parameter type `socket`
error[invalid-parameter-default] /Users/alexw/dev/typeshed/stdlib/asyncio/base_events.pyi:414:13 Default value of type `EllipsisType | ellipsis` is not assignable to annotated parameter type `bool | None`
Activity