Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(overloads): Expand finite sum types into a union of possible types#19431

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
mimre25 wants to merge2 commits intopython:master
base:master
Choose a base branch
Loading
frommimre25:expand-finite-types-for-overloads

Conversation

mimre25
Copy link

Fixes#17437

The changes here expand finite sum types when checking for overloads.

@mimre25mimre25force-pushed theexpand-finite-types-for-overloads branch from9b510b4 to2ad51aaCompareJuly 13, 2025 07:46
@github-actionsGitHub Actions
Copy link
Contributor

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

pytest-robotframework (https://github.com/detachhead/pytest-robotframework)- pytest_robotframework/__init__.py:569: error: No overload variant of "keyword" matches argument types "str | None", "tuple[str, ...] | None", "str | None", "bool"  [call-overload]- pytest_robotframework/__init__.py:569: note: Possible overload variants:- pytest_robotframework/__init__.py:569: note:     def keyword(*, name: str | None = ..., tags: tuple[str, ...] | None = ..., module: str | None = ..., wrap_context_manager: Literal[True]) -> _WrappedContextManagerKeywordDecorator- pytest_robotframework/__init__.py:569: note:     def keyword(*, name: str | None = ..., tags: tuple[str, ...] | None = ..., module: str | None = ..., wrap_context_manager: Literal[False]) -> _NonWrappedContextManagerKeywordDecorator- pytest_robotframework/__init__.py:569: note:     def keyword(*, name: str | None = ..., tags: tuple[str, ...] | None = ..., module: str | None = ..., wrap_context_manager: None = ...) -> _FunctionKeywordDecorator- pytest_robotframework/__init__.py:569: note:     def keyword(fn: Any) -> Any- pytest_robotframework/__init__.py:569: note:     def keyword(fn: Any) -> Neverpandas (https://github.com/pandas-dev/pandas)+ pandas/core/tools/numeric.py:224: error: Unused "type: ignore" comment  [unused-ignore]+ pandas/core/series.py:4828: error: Argument "inplace" to "_rename" of "NDFrame" has incompatible type "bool"; expected "Literal[False]"  [arg-type]packaging (https://github.com/pypa/packaging)+ src/packaging/metadata.py:439: error: Unused "type: ignore" comment  [unused-ignore]+ src/packaging/metadata.py:439: error: Argument 1 to "append" of "list" has incompatible type "Union[Message[str, str], bytes, Any, str, list[Union[Message[str, str], str]]]"; expected "str"  [arg-type]+ src/packaging/metadata.py:439: note: Error code "arg-type" not covered by "type: ignore" commentfreqtrade (https://github.com/freqtrade/freqtrade)+ freqtrade/plugins/pairlist/PercentChangePairList.py:237: error: Unused "type: ignore" comment  [unused-ignore]prefect (https://github.com/PrefectHQ/prefect)- src/prefect/futures.py:222: error: No overload variant of "result" of "State" matches argument types "bool", "bool"  [call-overload]+ src/prefect/futures.py:222: error: No overload variant of "result" of "State" matches argument types "Literal[True, False]", "bool"  [call-overload]- src/prefect/flows.py:1695: error: No overload variant of "track_viz_task" matches argument types "bool", "str", "dict[str, Any]"  [call-overload]- src/prefect/flows.py:1695: note: Possible overload variants:- src/prefect/flows.py:1695: note:     def track_viz_task(is_async: Literal[True], task_name: str, parameters: dict[str, Any], viz_return_value: Optional[Any] = ...) -> Coroutine[Any, Any, Any]- src/prefect/flows.py:1695: note:     def track_viz_task(is_async: Literal[False], task_name: str, parameters: dict[str, Any], viz_return_value: Optional[Any] = ...) -> Any+ src/prefect/tasks.py:1133: error: Incompatible return value type (got "Union[Coroutine[Any, Any, Any], Any]", expected "Union[R, State[R], None]")  [return-value]- src/prefect/tasks.py:1133: error: No overload variant of "track_viz_task" matches argument types "bool", "str", "dict[str, Any]", "Optional[Any]"  [call-overload]- src/prefect/tasks.py:1133: note: Possible overload variants:- src/prefect/tasks.py:1133: note:     def track_viz_task(is_async: Literal[True], task_name: str, parameters: dict[str, Any], viz_return_value: Optional[Any] = ...) -> Coroutine[Any, Any, Any]- src/prefect/tasks.py:1133: note:     def track_viz_task(is_async: Literal[False], task_name: str, parameters: dict[str, Any], viz_return_value: Optional[Any] = ...) -> Anymeson (https://github.com/mesonbuild/meson)+ mesonbuild/backend/backends.py:93:20: error: Item "type" of "type[Literal[TestProtocol.EXITCODE]] | type[Literal[TestProtocol.TAP]] | type[Literal[TestProtocol.GTEST]] | type[Literal[TestProtocol.RUST]]" has no attribute "EXITCODE"  [union-attr]+ mesonbuild/backend/backends.py:95:22: error: Item "type" of "type[Literal[TestProtocol.EXITCODE]] | type[Literal[TestProtocol.TAP]] | type[Literal[TestProtocol.GTEST]] | type[Literal[TestProtocol.RUST]]" has no attribute "GTEST"  [union-attr]+ mesonbuild/backend/backends.py:97:22: error: Item "type" of "type[Literal[TestProtocol.EXITCODE]] | type[Literal[TestProtocol.TAP]] | type[Literal[TestProtocol.GTEST]] | type[Literal[TestProtocol.RUST]]" has no attribute "RUST"  [union-attr]discord.py (https://github.com/Rapptz/discord.py)- discord/http.py:235: error: No overload variant of "__setitem__" of "list" matches argument types "str", "bool"  [call-overload]+ discord/http.py:235: error: No overload variant of "__setitem__" of "list" matches argument types "str", "Literal[True, False]"  [call-overload]hydpy (https://github.com/hydpy-dev/hydpy)- hydpy/auxs/statstools.py:1486: error: No overload variant of "fmin" matches argument types "Callable[[tuple[float, float, float, float]], float]", "Iterable[float]", "float", "float", "bool"  [call-overload]+ hydpy/auxs/statstools.py:1486: error: No overload variant of "fmin" matches argument types "Callable[[tuple[float, float, float, float]], float]", "Iterable[float]", "float", "float", "Literal[True, False]"  [call-overload]pydantic (https://github.com/pydantic/pydantic)- pydantic/fields.py:616: error: No overload variant of "Field" matches argument types "Any", "Any", "bool", "dict[Any, Any]"  [call-overload]+ pydantic/fields.py:616: error: No overload variant of "Field" matches argument types "Any", "Any", "Literal[True, False]", "dict[Any, Any]"  [call-overload]hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)+ tests/annotations/declarations.py:841: error: Argument "populate_full_signature" to "__call__" of "PBuilds" has incompatible type "bool"; expected "Literal[False]"  [arg-type]- tests/annotations/declarations.py:836: error: Need type annotation for "pout"  [var-annotated]- tests/annotations/declarations.py:837: error: Argument 1 to "__call__" of "PBuilds" has incompatible type "Callable[[int], str]"; expected "Callable[[VarArg(Never), KwArg(Never)], Never]"  [arg-type]+ tests/annotations/declarations.py:876: error: Argument "populate_full_signature" has incompatible type "bool"; expected "Literal[True]"  [arg-type]- tests/annotations/declarations.py:878: error: Unused "type: ignore" comment  [unused-ignore]- tests/annotations/declarations.py:895: error: Need type annotation for "maybe_full_sig"  [var-annotated]- tests/annotations/declarations.py:895: error: Argument 1 to "__call__" of "PBuilds" has incompatible type "Callable[[int], Any]"; expected "Callable[[VarArg(Never), KwArg(Never)], Never]"  [arg-type]- tests/annotations/declarations.py:897: error: Unused "type: ignore" comment  [unused-ignore]+ tests/annotations/declarations.py:895: error: Argument "zen_partial" to "__call__" of "PBuilds" has incompatible type "bool | None"; expected "Literal[False] | None"  [arg-type]+ tests/annotations/declarations.py:895: error: Argument "populate_full_signature" to "__call__" of "StdBuilds" has incompatible type "bool"; expected "Literal[True]"  [arg-type]+ tests/annotations/declarations.py:895: error: Argument "populate_full_signature" to "__call__" of "PBuilds" has incompatible type "bool"; expected "Literal[True]"  [arg-type]- tests/annotations/declarations.py:916: error: Unused "type: ignore" comment  [unused-ignore]+ tests/annotations/declarations.py:914: error: Argument "populate_full_signature" to "__call__" of "FullBuilds" has incompatible type "bool"; expected "Literal[True]"  [arg-type]xarray (https://github.com/pydata/xarray)+ xarray/core/utils.py:1052: error: Unused "type: ignore" comment  [unused-ignore]+ xarray/tests/test_distributed.py:268: error: Unused "type: ignore" comment  [unused-ignore]+ xarray/tests/test_distributed.py: note: In function "test_dask_distributed_zarr_integration_test":+ xarray/tests/test_distributed.py:272: error: Item "ZarrStore" of "ZarrStore | Any" has no attribute "compute"  [union-attr]mongo-python-driver (https://github.com/mongodb/mongo-python-driver)+ pymongo/asynchronous/database.py:932: error: Not all union combinations were tried because there are too many unions  [misc]spark (https://github.com/apache/spark)- python/pyspark/pandas/namespace.py:1140: error: No overload variant of "read_excel" matches argument types "BytesIO | Any", "str | int | list[str | int] | None", "int | list[int]", "list[Any] | None", "list[int] | None", "int | str | list[int | str] | Callable[[str], bool] | None", "dict[str, str | dtype[Any] | ExtensionDtype] | None", "str | None", "dict[Any, Any] | None", "Any | None", "Any | None", "int | list[int] | None", "int | None", "Any | None", "bool", "bool", "bool | list[Any] | dict[Any, Any]", "Callable[..., Any] | None", "str | None", "str | None", "int", "dict[str, Any]"  [call-overload]+ python/pyspark/pandas/namespace.py:1140: error: No overload variant of "read_excel" matches argument types "BytesIO | Any", "str | int | list[str | int] | None", "int | list[int]", "list[Any] | None", "list[int] | None", "int | str | list[int | str] | Callable[[str], bool] | None", "dict[str, str | dtype[Any] | ExtensionDtype] | None", "str | None", "dict[Any, Any] | None", "Any | None", "Any | None", "int | list[int] | None", "int | None", "Any | None", "Literal[True, False]", "Literal[True, False]", "bool | list[Any] | dict[Any, Any]", "Callable[..., Any] | None", "str | None", "str | None", "int", "dict[str, Any]"  [call-overload]- python/pyspark/pandas/testing.py:241: error: No overload variant of "assert_series_equal" matches argument types "Series[Any]", "Series[Any]", "bool", "bool | Literal['equiv']", "bool", "bool", "bool", "bool", "bool", "bool", "bool", "bool", "float", "float", "str", "bool", "bool"  [call-overload]+ python/pyspark/pandas/testing.py:241: error: Not all union combinations were tried because there are too many unions  [misc]- python/pyspark/pandas/testing.py:241: note: Error code "call-overload" not covered by "type: ignore" comment+ python/pyspark/pandas/testing.py:241: note: Error code "misc" not covered by "type: ignore" comment- python/pyspark/pandas/testing.py:241: note: Possible overload variants:- python/pyspark/pandas/testing.py:241: note:     def assert_series_equal(left: Series[Any], right: Series[Any], check_dtype: bool | Literal['equiv'] = ..., check_index_type: bool | Literal['equiv'] = ..., check_series_type: bool = ..., check_names: bool = ..., check_exact: bool = ..., check_datetimelike_compat: bool = ..., check_categorical: bool = ..., check_category_order: bool = ..., check_freq: bool = ..., check_flags: bool = ..., rtol: float = ..., atol: float = ..., obj: str = ..., *, check_index: Literal[False], check_like: Literal[False] = ...) -> None- python/pyspark/pandas/testing.py:241: note:     def assert_series_equal(left: Series[Any], right: Series[Any], check_dtype: bool | Literal['equiv'] = ..., check_index_type: bool | Literal['equiv'] = ..., check_series_type: bool = ..., check_names: bool = ..., check_exact: bool = ..., check_datetimelike_compat: bool = ..., check_categorical: bool = ..., check_category_order: bool = ..., check_freq: bool = ..., check_flags: bool = ..., rtol: float = ..., atol: float = ..., obj: str = ..., *, check_index: Literal[True] = ..., check_like: bool = ...) -> None+ python/pyspark/pandas/testing.py:257: error: Argument "check_index" to "assert_series_equal" has incompatible type "bool"; expected "Literal[False]"  [arg-type]+ python/pyspark/pandas/testing.py:258: error: Argument "check_like" to "assert_series_equal" has incompatible type "bool"; expected "Literal[False]"  [arg-type]core (https://github.com/home-assistant/core)+ homeassistant/components/shopping_list/__init__.py:390: error: Unused "type: ignore[arg-type, return-value]" comment  [unused-ignore]

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant
@mimre25

[8]ページ先頭

©2009-2025 Movatter.jp