Detailed 'signature incompatible with supertype' for non-callables#15263
Merged
hauntsaninja merged 5 commits intopython:masterfrom May 21, 2023
Merged
Conversation
This comment has been minimized.
This comment has been minimized.
Contributor
Author
|
p.s. given how common cases like this are + discord/channel.py:223: note: Superclass:
+ discord/channel.py:223: note: ChannelType
+ discord/channel.py:223: note: Subclass:
+ discord/channel.py:223: note: Literal[ChannelType.text, ChannelType.news]would it be useful for this case to emit the "This violates the Liskov substitution principle" notes too, or is it too much text and/or we're being too prescriptive? cc @ChetanKhanna who authored (and @JukkaL who reviewed) #8866 |
This comment has been minimized.
This comment has been minimized.
Contributor
Author
|
|
Contributor
|
Diff from mypy_primer, showing the effect of this PR on open source code: Tanjun (https://github.com/FasterSpeeding/Tanjun)
+ tanjun/context/slash.py:1044: note: Superclass:
+ tanjun/context/slash.py:1044: note: Optional[ExecutableCommand[SlashContext]]
+ tanjun/context/slash.py:1044: note: Subclass:
+ tanjun/context/slash.py:1044: note: Optional[BaseSlashCommand]
+ tanjun/context/message.py:130: note: Superclass:
+ tanjun/context/message.py:130: note: Optional[ExecutableCommand[MessageContext]]
+ tanjun/context/message.py:130: note: Subclass:
+ tanjun/context/message.py:130: note: Optional[MessageCommand[Any]]
+ tanjun/context/menu.py:101: note: Superclass:
+ tanjun/context/menu.py:101: note: Optional[ExecutableCommand[MenuContext]]
+ tanjun/context/menu.py:101: note: Subclass:
+ tanjun/context/menu.py:101: note: Optional[MenuCommand[Any, Any]]
manticore (https://github.com/trailofbits/manticore)
+ manticore/platforms/linux.py:359: note: Superclass:
+ manticore/platforms/linux.py:359: note: bool
+ manticore/platforms/linux.py:359: note: Subclass:
+ manticore/platforms/linux.py:359: note: def closed(self) -> bool
Auto-Split (https://github.com/Avasam/Auto-Split)
+ src/capture_method/__init__.py:102: note: Superclass:
+ src/capture_method/__init__.py:102: note: Subclass:
+ src/capture_method/__init__.py:102: note: Superclass:
+ src/capture_method/__init__.py:102: note: Subclass:
+ src/capture_method/__init__.py:102: note: Superclass:
+ src/capture_method/__init__.py:102: note: Subclass:
sublime_debugger (https://github.com/daveleroy/sublime_debugger)
+ modules/ui/html.py:244: note: Superclass:
+ modules/ui/html.py:244: note: float | None
+ modules/ui/html.py:244: note: Subclass:
+ modules/ui/html.py:244: note: def width(self) -> float
+ modules/ui/html.py:244: note: Superclass:
+ modules/ui/html.py:244: note: float | None
+ modules/ui/html.py:244: note: Subclass:
+ modules/ui/html.py:244: note: def width(self) -> float
+ modules/breakpoints/data_breakpoints.py:26: note: Superclass:
+ modules/breakpoints/data_breakpoints.py:26: note: str
+ modules/breakpoints/data_breakpoints.py:26: note: Subclass:
+ modules/breakpoints/data_breakpoints.py:26: note: str | None
operator (https://github.com/canonical/operator)
+ ops/model.py:783: note: Superclass:
+ ops/model.py:783: note: Subclass:
+ ops/framework.py:1252: note: Superclass:
+ ops/framework.py:1252: note: Subclass:
steam.py (https://github.com/Gobot1234/steam.py)
+ steam/ext/commands/utils.py:36: note: Superclass:
+ steam/ext/commands/utils.py:36: note: Subclass:
+ steam/ext/commands/utils.py:47: note: Superclass:
+ steam/ext/commands/utils.py:47: note: Subclass:
+ steam/ext/commands/help.py:130: note: Superclass:
+ steam/ext/commands/help.py:130: note: Err
+ steam/ext/commands/help.py:130: note: Subclass:
+ steam/ext/commands/help.py:130: note: def on_error(self, ctx: Context, error: Exception) -> Coroutine[Any, Any, None]
spark (https://github.com/apache/spark)
+ python/pyspark/ml/classification.py:877: note: Superclass:
+ python/pyspark/ml/classification.py:877: note: LinearSVCTrainingSummary
+ python/pyspark/ml/classification.py:877: note: Subclass:
+ python/pyspark/ml/classification.py:877: note: def summary(self) -> LinearSVCTrainingSummary
+ python/pyspark/ml/classification.py:3323: note: Superclass:
+ python/pyspark/ml/classification.py:3323: note: MultilayerPerceptronClassificationTrainingSummary
+ python/pyspark/ml/classification.py:3323: note: Subclass:
+ python/pyspark/ml/classification.py:3323: note: def summary(self) -> MultilayerPerceptronClassificationTrainingSummary
prefect (https://github.com/PrefectHQ/prefect)
+ src/prefect/utilities/annotations.py:48: note: Superclass:
+ src/prefect/utilities/annotations.py:48: note: Subclass:
+ src/prefect/_internal/concurrency/api.py:158: note: Superclass:
+ src/prefect/_internal/concurrency/api.py:158: note: abstractstaticmethod[[Callable[[], T] | Call[T], float | None, Iterable[Call[Any]] | None], T]
+ src/prefect/_internal/concurrency/api.py:158: note: Subclass:
+ src/prefect/_internal/concurrency/api.py:158: note: @staticmethod
+ src/prefect/_internal/concurrency/api.py:158: note: def [T] wait_for_call_in_loop_thread(Callable[[], Awaitable[T]] | Call[Awaitable[T]], /, timeout: float | None = ..., done_callbacks: Iterable[Call[Any]] | None = ..., contexts: Iterable[AbstractContextManager[Any]] | None = ...) -> Coroutine[Any, Any, Awaitable[T]]
+ src/prefect/_internal/concurrency/api.py:176: note: Superclass:
+ src/prefect/_internal/concurrency/api.py:176: note: abstractstaticmethod[[Callable[[], T] | Call[T], float | None, Iterable[Call[Any]] | None], T]
+ src/prefect/_internal/concurrency/api.py:176: note: Subclass:
+ src/prefect/_internal/concurrency/api.py:176: note: @staticmethod
+ src/prefect/_internal/concurrency/api.py:176: note: def [T] wait_for_call_in_new_thread(Callable[[], T] | Call[T], /, timeout: float | None = ..., done_callbacks: Iterable[Call[Any]] | None = ...) -> Coroutine[Any, Any, Call[T]]
+ src/prefect/_internal/concurrency/api.py:214: note: Superclass:
+ src/prefect/_internal/concurrency/api.py:214: note: abstractstaticmethod[[Callable[[], T] | Call[T], float | None, Iterable[Call[Any]] | None], T]
+ src/prefect/_internal/concurrency/api.py:214: note: Subclass:
+ src/prefect/_internal/concurrency/api.py:214: note: @staticmethod
+ src/prefect/_internal/concurrency/api.py:214: note: def [T] wait_for_call_in_loop_thread(Callable[[], Awaitable[T]] | Callable[[], Awaitable[T]] | Call[Awaitable[T]], /, timeout: float | None = ..., done_callbacks: Iterable[Call[Any]] | None = ..., contexts: Iterable[AbstractContextManager[Any]] | None = ...) -> Awaitable[T]
+ src/prefect/_internal/concurrency/api.py:235: note: Superclass:
+ src/prefect/_internal/concurrency/api.py:235: note: abstractstaticmethod[[Callable[[], T] | Call[T], float | None, Iterable[Call[Any]] | None], T]
+ src/prefect/_internal/concurrency/api.py:235: note: Subclass:
+ src/prefect/_internal/concurrency/api.py:235: note: @staticmethod
+ src/prefect/_internal/concurrency/api.py:235: note: def [T] wait_for_call_in_new_thread(Callable[[], T] | Call[T], /, timeout: float | None = ..., done_callbacks: Iterable[Call[Any]] | None = ...) -> Call[T]
+ src/prefect/results.py:402: note: Superclass:
+ src/prefect/results.py:402: note: abstractclassmethod[type[BaseResult[R]], [R, KwArg(Any)], Coroutine[Any, Any, BaseResult[R]]]
+ src/prefect/results.py:402: note: Subclass:
+ src/prefect/results.py:402: note: @classmethod
+ src/prefect/results.py:402: note: def [R] create(cls, obj: R, cache_object: bool = ...) -> Coroutine[Any, Any, UnpersistedResult]
+ src/prefect/results.py:439: note: Superclass:
+ src/prefect/results.py:439: note: abstractclassmethod[type[BaseResult[R]], [R, KwArg(Any)], Coroutine[Any, Any, BaseResult[R]]]
+ src/prefect/results.py:439: note: Subclass:
+ src/prefect/results.py:439: note: @classmethod
+ src/prefect/results.py:439: note: def [R] create(cls, obj: R) -> Coroutine[Any, Any, LiteralResult]
+ src/prefect/results.py:511: note: Superclass:
+ src/prefect/results.py:511: note: abstractclassmethod[type[BaseResult[R]], [R, KwArg(Any)], Coroutine[Any, Any, BaseResult[R]]]
+ src/prefect/results.py:511: note: Subclass:
+ src/prefect/results.py:511: note: @classmethod
+ src/prefect/results.py:511: note: def [R] create(cls, obj: R, storage_block: WritableFileSystem, storage_block_id: UUID, storage_key_fn: Callable[[], str], serializer: Serializer[Any], cache_object: bool = ...) -> Coroutine[Any, Any, PersistedResult]
ibis (https://github.com/ibis-project/ibis)
+ ibis/common/grounds.py:93: note: Superclass:
+ ibis/common/grounds.py:93: note: classmethod[type, [VarArg(Any), KwArg(Any)], Any]
+ ibis/common/grounds.py:93: note: Subclass:
+ ibis/common/grounds.py:93: note: @classmethod
+ ibis/common/grounds.py:93: note: def __create__(cls, *args: Any, **kwargs: Any) -> Annotable
+ ibis/common/grounds.py:175: note: Superclass:
+ ibis/common/grounds.py:175: note: classmethod[type, [VarArg(Any), KwArg(Any)], Any]
+ ibis/common/grounds.py:175: note: Subclass:
+ ibis/common/grounds.py:175: note: @classmethod
+ ibis/common/grounds.py:175: note: def __create__(cls, *args: Any, **kwargs: Any) -> Singleton
+ ibis/expr/operations/window.py:47: note: Superclass:
+ ibis/expr/operations/window.py:47: note: DataType
+ ibis/expr/operations/window.py:47: note: Subclass:
+ ibis/expr/operations/window.py:47: note: def output_dtype(self) -> DataType
+ ibis/backends/datafusion/__init__.py:64: note: Superclass:
+ ibis/backends/datafusion/__init__.py:64: note: str | None
+ ibis/backends/datafusion/__init__.py:64: note: Subclass:
+ ibis/backends/datafusion/__init__.py:64: note: def current_database(self) -> str
+ ibis/backends/pyspark/__init__.py:570: note: Superclass:
+ ibis/backends/pyspark/__init__.py:570: note: Subclass:
+ ibis/backends/dask/__init__.py:96: note: Superclass:
+ ibis/backends/dask/__init__.py:96: note: Subclass:
+ ibis/backends/trino/__init__.py:26: note: Superclass:
+ ibis/backends/trino/__init__.py:26: note: str
+ ibis/backends/trino/__init__.py:26: note: Subclass:
+ ibis/backends/trino/__init__.py:26: note: def current_database(self) -> str
+ ibis/backends/trino/__init__.py:26: note: Superclass:
+ ibis/backends/trino/__init__.py:26: note: str | None
+ ibis/backends/trino/__init__.py:26: note: Subclass:
+ ibis/backends/trino/__init__.py:26: note: def current_database(self) -> str
+ ibis/backends/duckdb/__init__.py:62: note: Superclass:
+ ibis/backends/duckdb/__init__.py:62: note: str
+ ibis/backends/duckdb/__init__.py:62: note: Subclass:
+ ibis/backends/duckdb/__init__.py:62: note: def current_database(self) -> str
+ ibis/backends/duckdb/__init__.py:62: note: Superclass:
+ ibis/backends/duckdb/__init__.py:62: note: str | None
+ ibis/backends/duckdb/__init__.py:62: note: Subclass:
+ ibis/backends/duckdb/__init__.py:62: note: def current_database(self) -> str
discord.py (https://github.com/Rapptz/discord.py)
+ discord/invite.py:507: note: Superclass:
+ discord/invite.py:507: note: int
+ discord/invite.py:507: note: Subclass:
+ discord/invite.py:507: note: str
+ discord/channel.py:223: note: Superclass:
+ discord/channel.py:223: note: ChannelType
+ discord/channel.py:223: note: Subclass:
+ discord/channel.py:223: note: Literal[ChannelType.text, ChannelType.news]
+ discord/channel.py:1341: note: Superclass:
+ discord/channel.py:1341: note: ChannelType
+ discord/channel.py:1341: note: Subclass:
+ discord/channel.py:1341: note: Literal[ChannelType.voice]
+ discord/channel.py:1580: note: Superclass:
+ discord/channel.py:1580: note: ChannelType
+ discord/channel.py:1580: note: Subclass:
+ discord/channel.py:1580: note: Literal[ChannelType.stage_voice]
+ discord/channel.py:1845: note: Superclass:
+ discord/channel.py:1845: note: ChannelType
+ discord/channel.py:1845: note: Subclass:
+ discord/channel.py:1845: note: Literal[ChannelType.category]
+ discord/channel.py:2260: note: Superclass:
+ discord/channel.py:2260: note: ChannelType
+ discord/channel.py:2260: note: Subclass:
+ discord/channel.py:2260: note: Literal[ChannelType.forum]
+ discord/webhook/sync.py:406: note: Superclass:
+ discord/webhook/sync.py:406: note: Subclass:
+ discord/webhook/async_.py:774: note: Superclass:
+ discord/webhook/async_.py:774: note: Subclass:
+ discord/ui/select.py:298: note: Superclass:
+ discord/ui/select.py:298: note: list[str | User | Member | Role | AppCommandChannel | AppCommandThread | Role | Member | Role | User]
+ discord/ui/select.py:298: note: Subclass:
+ discord/ui/select.py:298: note: list[str]
+ discord/ui/select.py:446: note: Superclass:
+ discord/ui/select.py:446: note: list[str | User | Member | Role | AppCommandChannel | AppCommandThread | Role | Member | Role | User]
+ discord/ui/select.py:446: note: Subclass:
+ discord/ui/select.py:446: note: list[Member | User]
+ discord/ui/select.py:515: note: Superclass:
+ discord/ui/select.py:515: note: list[str | User | Member | Role | AppCommandChannel | AppCommandThread | Role | Member | Role | User]
+ discord/ui/select.py:515: note: Subclass:
+ discord/ui/select.py:515: note: list[Role]
+ discord/ui/select.py:579: note: Superclass:
+ discord/ui/select.py:579: note: list[str | User | Member | Role | AppCommandChannel | AppCommandThread | Role | Member | Role | User]
+ discord/ui/select.py:579: note: Subclass:
+ discord/ui/select.py:579: note: list[Member | User | Role]
+ discord/ui/select.py:668: note: Superclass:
+ discord/ui/select.py:668: note: list[str | User | Member | Role | AppCommandChannel | AppCommandThread | Role | Member | Role | User]
+ discord/ui/select.py:668: note: Subclass:
+ discord/ui/select.py:668: note: list[AppCommandChannel | AppCommandThread]
|
Contributor
Author
|
Seeing duplication in AutoSplit: I don't think we should address it here. Rather, let's address holistically in #15273. |
hauntsaninja
approved these changes
May 21, 2023
Collaborator
hauntsaninja
left a comment
There was a problem hiding this comment.
Thanks, looks great!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously the "signature incompatible with supertype" error only included detailed comparison when both types are callables; now it will compare in all cases.