Skip to content

unnecessary_dict_kwargs doc - a note on type checking benefits #18666

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 1 commit into
base: main
Choose a base branch
from

Conversation

Andrej730
Copy link

Summary

Recently stumbled upon type checkers typically not being able to verify kwargs when they're unpacked from just constructed dictionary:

Snippet:

def foo(bar: int):
    return bar + 1


print(foo(**{"bar": 2}))
# No typing errors.
print(foo(**{"bar":2, "baz":22}))

pyright-play
mypy-play

And I've found that PIE804 can be helpful to highlight those cases.
Perhaps a note in PIE804 documentation can help advertise this rule as the one also enchancing type safety.

@ntBre ntBre added the documentation Improvements or additions to documentation label Jun 13, 2025
@ntBre ntBre self-requested a review June 13, 2025 22:34
Copy link
Contributor

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants