Skip to content
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

Spurious pass when Sequence[int | None] passed to behavior requiring Iterable[not-None] #1766

Open
nathanielmanistaatgoogle opened this issue Sep 14, 2024 · 2 comments
Labels
bug cat: control flow control flow analysis

Comments

@nathanielmanistaatgoogle
Copy link
Member

nathanielmanistaatgoogle commented Sep 14, 2024

With pytype-2024.9.13 the file content

Q = sum([0, 1, 2, 3, None])
T = sum([None, 3])
W = sum([None, None])

is flagged with

temp-2024-09-14-pytype/haha.py:3:1: error: in <module>: Built-in function sum was called with the wrong arguments [wrong-arg-types]
         Expected: (iterable: Iterable[_Summable])
  Actually passed: (iterable: List[None])
  Attributes of protocol _Summable are not implemented on None: __add__

W = sum([None, None])~~~~~~~~~~~~~~~~~~~~
W = sum([None, None])



For more details, see https://google.github.io/pytype/errors.html#wrong-arg-types

but that's insufficient; all three of those lines ought have been flagged with wrong-arg-types (none of those three lines will evaluate without raising a TypeError).

@nathanielmanistaatgoogle
Copy link
Member Author

(I'm not sure if this issue has any relationship with issue 365. I feel like probably not, but... maybe?)

@frigus02 frigus02 added bug cat: control flow control flow analysis labels Sep 16, 2024
@frigus02
Copy link
Contributor

Yeah, that's a bug. Just confirmed it's not new and already present in 2024.04.11.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug cat: control flow control flow analysis
Projects
None yet
Development

No branches or pull requests

2 participants