Skip to content

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

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open

Conversation

Jdwashin9
Copy link

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.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

@lesliehuh
Copy link

lesliehuh commented Apr 30, 2025

This comment has been minimized.

@Jdwashin9
Copy link
Author

Jdwashin9 commented Apr 30, 2025

@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
Copy link
Collaborator

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
Copy link
Collaborator

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)

def f3(x: Any):
return g(*x)

from typing import Optional
Copy link
Collaborator

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?

@sterliakov
Copy link
Collaborator

But the primer results look amazing - please keep going, let's get this working!

This comment has been minimized.

This comment has been minimized.

Copy link
Contributor

github-actions bot commented May 2, 2025

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]

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.

Detect impossible unpacking?
3 participants