KEMBAR78
Fix crash when overriding with unpacked TypedDict by ilevkivskyi · Pull Request #17359 · python/mypy · GitHub
Skip to content

Conversation

ilevkivskyi
Copy link
Member

Fixes #17208

While writing the fix (that is trivial), I could not notice that the relevant code simply assumes functions can have nothing but positional parameters. This could lead really misleading error messages, so I decided to fix this as well.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

ibis (https://github.com/ibis-project/ibis)
- ibis/backends/impala/__init__.py:760: error: Argument 2 of "drop_table" is incompatible with supertype "SQLBackend"; supertype defines the argument type as "tuple[str, str] | str | None"  [override]
- ibis/backends/impala/__init__.py:760: note: This violates the Liskov substitution principle
- ibis/backends/impala/__init__.py:760: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
+ ibis/backends/impala/__init__.py:759: error: Signature of "drop_table" incompatible with supertype "SQLBackend"  [override]
+ ibis/backends/impala/__init__.py:759: note:      Superclass:
+ ibis/backends/impala/__init__.py:759: note:          def drop_table(self, name: str, database: tuple[str, str] | str | None = ..., force: bool = ...) -> None
+ ibis/backends/impala/__init__.py:759: note:      Subclass:
+ ibis/backends/impala/__init__.py:759: note:          def drop_table(self, name: str, *, database: str | None = ..., force: bool = ...) -> None
- ibis/backends/clickhouse/__init__.py:513: error: Argument 2 of "create_database" is incompatible with supertype "CanCreateDatabase"; supertype defines the argument type as "str | None"  [override]
- ibis/backends/clickhouse/__init__.py:513: note: This violates the Liskov substitution principle
- ibis/backends/clickhouse/__init__.py:513: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
- ibis/backends/clickhouse/__init__.py:513: error: Argument 3 of "create_database" is incompatible with supertype "CanCreateDatabase"; supertype defines the argument type as "bool"  [override]
+ ibis/backends/clickhouse/__init__.py:512: error: Signature of "create_database" incompatible with supertype "CanCreateDatabase"  [override]
+ ibis/backends/clickhouse/__init__.py:512: note:      Superclass:
+ ibis/backends/clickhouse/__init__.py:512: note:          def create_database(self, name: str, catalog: str | None = ..., force: bool = ...) -> None
+ ibis/backends/clickhouse/__init__.py:512: note:      Subclass:
+ ibis/backends/clickhouse/__init__.py:512: note:          def create_database(self, name: str, *, force: bool = ..., engine: str = ...) -> None

@ilevkivskyi
Copy link
Member Author

The second example in the mypy_primer is exactly what I am talking about.

@ilevkivskyi ilevkivskyi merged commit b8a0260 into python:master Jun 11, 2024
@ilevkivskyi ilevkivskyi deleted the fix-unpack-td-over branch June 11, 2024 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using unpack to keep parameters when creating httpx subclass leads to crash

1 participant