Skip to content

Infer type for partial generic type from assignment #8036

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 4 commits into from
Nov 29, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix test cases
  • Loading branch information
JukkaL committed Nov 29, 2019
commit eff55056d97450a9477813fb368f2e1eb7a9a376
10 changes: 7 additions & 3 deletions mypy/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,13 +599,17 @@ def remove_duplicates(self, errors: List[ErrorTuple]) -> List[ErrorTuple]:
while i < len(errors):
dup = False
j = i - 1
conflicts = False
while (j >= 0 and errors[j][0] == errors[i][0] and
errors[j][1] == errors[i][1]):
if errors[j][3].startswith('Got:'):
conflicts = True # Member conflicts reporting
if (errors[j][3] == errors[i][3] and
# Allow duplicate notes in overload conflicts reporting.
not (errors[i][3] == 'note' and
errors[i][4].strip() in allowed_duplicates
or errors[i][4].strip().startswith('def ')) and
not ((errors[i][3] == 'note' and
errors[i][4].strip() in allowed_duplicates)
or (errors[i][4].strip().startswith('def ') and
conflicts)) and
errors[j][4] == errors[i][4]): # ignore column
dup = True
break
Expand Down
4 changes: 2 additions & 2 deletions test-data/unit/check-inference.test
Original file line number Diff line number Diff line change
Expand Up @@ -1535,13 +1535,13 @@ def add():
[case testSpecialCaseEmptyListInitialization]
def f(blocks: Any): # E: Name 'Any' is not defined \
# N: Did you forget to import it from "typing"? (Suggestion: "from typing import Any")
to_process = [] # E: Need type annotation for 'to_process' (hint: "to_process: List[<type>] = ...")
to_process = []
to_process = list(blocks)
[builtins fixtures/list.pyi]

[case testSpecialCaseEmptyListInitialization2]
def f(blocks: object):
to_process = [] # E: Need type annotation for 'to_process' (hint: "to_process: List[<type>] = ...")
to_process = []
to_process = list(blocks) # E: No overload variant of "list" matches argument type "object" \
# N: Possible overload variant: \
# N: def [T] __init__(self, x: Iterable[T]) -> List[T] \
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy