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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you requested my review, this comment still applies - I don't see any reason for this whole block of code to exist...

@@ -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]

@Jdwashin9 Jdwashin9 requested a review from sterliakov May 7, 2025 14:43
@sterliakov
Copy link
Collaborator

BTW, if this is some kind of college/uni/course assignment and you need to contribute a PR with at least N lines of code, please reach out to your professor and let them know that's not how OSS contributions usually work - often a great PR is a 2-line diff, especially when you're a new contributor not deeply familiar with the whole codebase.

If you still need to fulfil that requirement, consider adding more helpful tests (I'll be open to reviewing even some unrelated tests that aren't already present) instead of trying to add unrelated code.

@Jdwashin9
Copy link
Author

Hello, I just wanted to reach out and say that our class, and our window to contribute to this OSS, has ended. @lesliehuh and I appreciate your feedback and assistance on the contributions we did make.

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