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

Do not strip away generic parameters explicitly set to Any #467

Merged
merged 1 commit into from
Feb 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- Do not strip away generic parameters explicitly set to
`Any` (#467)
- Fix bug that led to some overloaded calls incorrectly
resolving to `Any` (#462)
- Support `__init__` and `__new__` signatures from typeshed (#429)
Expand Down
2 changes: 0 additions & 2 deletions pyanalyze/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1069,8 +1069,6 @@ def _value_of_origin_args(
origin = _maybe_get_extra(origin)
if args:
args_vals = [_type_from_runtime(val, ctx) for val in args]
if all(isinstance(val, AnyValue) for val in args_vals):
return _maybe_typed_value(origin)
return GenericValue(origin, args_vals)
else:
return _maybe_typed_value(origin)
Expand Down
5 changes: 3 additions & 2 deletions pyanalyze/test_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,12 @@ def rgx(m: Match[str], p: Pattern[bytes]) -> None:

@assert_passes()
def test_generic(self):
from typing import List
from typing import List, Any

def capybara(x: List[int], y: List) -> None:
def capybara(x: List[int], y: List, z: List[Any]) -> None:
assert_is_value(x, GenericValue(list, [TypedValue(int)]))
assert_is_value(y, TypedValue(list))
assert_is_value(z, GenericValue(list, [AnyValue(AnySource.explicit)]))

@assert_passes()
def test_supports_int(self):
Expand Down