We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi folks,
import json from typing import Any def parse_json(s: str) -> dict[str, Any] | list[dict[str, Any]]: return json.loads(s) def foo() -> list[dict[str, Any]]: res = [] l = parse_json('[{"abc": 123}]') assert isinstance(l, list) res.extend(l) return res def bar() -> list[dict[str, Any]]: l = parse_json('[{"abc": 123}]') assert isinstance(l, list) return l if __name__ == '__main__': assert foo() == [{'abc': 123}]
I'm not sure why pytype is unhappy with foo (but bar is fine). It looks like a bug to me.
~$ mypy toy.py Success: no issues found in 1 source file ~$ pytype toy.py Computing dependencies Analyzing 1 sources with 0 local dependencies ninja: Entering directory `.pytype' [1/1] check toy FAILED: /home/user/.pytype/pyi/toy.pyi /usr/bin/python3 -m pytype.main --imports_info /home/user/.pytype/imports/toy.imports --module-name toy --platform linux -V 3.10 -o /home/user/.pytype/pyi/toy.pyi --analyze-annotated --nofail --quick /home/user/toy.py File "/home/user/toy.py", line 14, in foo: bad return type [bad-return-type] Expected: List[Dict[str, Any]] Actually returned: List[str] For more details, see https://google.github.io/pytype/errors.html#bad-return-type ninja: build stopped: subcommand failed. Leaving directory '.pytype' ~$ pytype --version 2024.03.19
Cheers.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi folks,
I'm not sure why pytype is unhappy with foo (but bar is fine). It looks like a bug to me.
Cheers.
The text was updated successfully, but these errors were encountered: