-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Missing args callable #18990
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Missing args callable #18990
Conversation
for more information, see https://pre-commit.ci
This comment has been minimized.
This comment has been minimized.
Delete unrelated changes
for more information, see https://pre-commit.ci
Changed wrong files This reverts commit c4d3d0a.
Accidentally deleted the wrong changes This reverts commit 17ebfea.
for more information, see https://pre-commit.ci
accidentally committed local container files with changes
Accidentally included local container files in commit
cleaned up extra space
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
commit 91703e53b3e71b68faf512d310c72a16f0c1f185 resolves Issue #18994 |
This comment has been minimized.
This comment has been minimized.
@sterliakov ready for your review, when you have time. Thanks again for assisting with the internal error issue. |
if name is not None and kind in (ARG_NAMED, ARG_POS): | ||
if name not in arg_names_set: | ||
if target_name == "misc": | ||
continue # Skip error for miscellaneous/unknown classes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many questions here... First, why is this code block preceding a docstring?
Second, there's no special-cased "misc" typing construct, this simply shouldn't exist. But fortunately this whole block starting from is_constructor_call = ...
line is... doing nothing? Is this some kind of merge artifact? I don't see any use of these newly declared variables.
@@ -59,3 +59,4 @@ class dict(Mapping[KT, VT]): | |||
@overload | |||
def get(self, k: KT, default: Union[KT, T]) -> Union[VT, T]: pass | |||
def __len__(self) -> int: ... | |||
import _typeshed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move this to the very top (even though that may affect line numbers in 1-2 existing tests, that's simple enough)
test-data/unit/check-functions.test
Outdated
def f3(x: Any): | ||
return g(*x) | ||
|
||
from typing import Optional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it need to be separated and not at the top? Why?
But the primer results look amazing - please keep going, let's get this working! |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Diff from mypy_primer, showing the effect of this PR on open source code: prefect (https://github.com/PrefectHQ/prefect)
+ src/prefect/_internal/pydantic/v2_validated_func.py:50: error: Argument after ** must be a mapping, not "Union[type[Any], dict[str, Any], None]" [arg-type]
pandas (https://github.com/pandas-dev/pandas)
+ pandas/io/excel/_xlsxwriter.py:259: error: Expected iterable as variadic argument [misc]
antidote (https://github.com/Finistere/antidote)
+ src/antidote/core/_inject.py:348: error: Expected iterable as variadic argument [misc]
+ src/antidote/core/_inject.py:348: error: Argument after ** must be a mapping, not "dict[str, Any] | None" [arg-type]
xarray (https://github.com/pydata/xarray)
+ xarray/core/common.py: note: In member "squeeze" of class "DataWithCoords":
+ xarray/core/common.py:460: error: Keywords must be strings [misc]
+ xarray/core/dataset.py: note: In member "_stack_once" of class "Dataset":
+ xarray/core/dataset.py:5085: error: Keywords must be strings [misc]
pandera (https://github.com/pandera-dev/pandera)
+ tests/pandas/test_extensions.py:57: error: Argument after ** must be a mapping, not "object" [arg-type]
+ tests/pandas/test_extensions.py:99: error: Argument after ** must be a mapping, not "object" [arg-type]
openlibrary (https://github.com/internetarchive/openlibrary)
+ openlibrary/core/imports.py: note: In member "add_items" of class "Batch":
+ openlibrary/core/imports.py:131: error: Argument after ** must be a mapping, not "str | dict[Any, Any]" [arg-type]
jax (https://github.com/google/jax)
+ jax/_src/numpy/einsum.py:566: error: Argument after ** must be a mapping, not "NamedSharding | None" [arg-type]
|
Fixes #18783
Updated suggested code from prototype and modified check_call_expr_with_callee_type so that all required named or positional arguments are supplied during constructor calls. Tests were also written to verify that missing arguments raise type-checking errors.