Skip to content

builtins.sum: Items in the iterable must support addition with int if no start value is given #8000

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

Merged
merged 6 commits into from
Jun 13, 2022

Conversation

AlexWaygood
Copy link
Member

Closes #7574 (cc. @jpy-git). I think this is just about the best we can do without introducing many false-positive errors.

Comment on lines +25 to +27
# TODO: these pass pyright with the current stubs, but mypy erroneously emits an error:
# sum([3, Fraction(7, 22), complex(8, 0), 9.83])
# sum([3, Decimal('0.98')])
Copy link
Member Author

Choose a reason for hiding this comment

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

mypy also emits an error for these tests on current master, so this PR wouldn't be introducing a regression here.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@AlexWaygood
Copy link
Member Author

Any thoughts from anyone on whether this is a good idea? :)

@AlexWaygood AlexWaygood marked this pull request as draft June 8, 2022 10:35
@github-actions

This comment has been minimized.

@AlexWaygood AlexWaygood marked this pull request as ready for review June 8, 2022 19:02
@github-actions
Copy link
Contributor

github-actions bot commented Jun 8, 2022

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@AlexWaygood AlexWaygood requested a review from srittau June 8, 2022 19:09
@AlexWaygood AlexWaygood merged commit 1828ba2 into python:master Jun 13, 2022
@AlexWaygood AlexWaygood deleted the sum branch June 13, 2022 10:25
@JelleZijlstra
Copy link
Member

This just found a bug where we were doing sum() on a type that defined __add__ but not __radd__. Thanks!

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.

sum stub too permissive
4 participants