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

Output broken for multiline messages #66

Closed
zero323 opened this issue Oct 7, 2021 · 0 comments · Fixed by #67
Closed

Output broken for multiline messages #66

zero323 opened this issue Oct 7, 2021 · 0 comments · Fixed by #67
Labels
bug Something isn't working

Comments

@zero323
Copy link
Contributor

zero323 commented Oct 7, 2021

Given following test case

- case: break_following
  main: |
    from typing import overload, TypeVar

    T = TypeVar("T", int, str)
    
    @overload
    def f(x: int) -> int: ...
    @overload
    def f(x: str) -> str: ...
    def f(x: T) -> T:
      return x

    reveal_type(f([1, 2, 3]))  # N: Revealed type is "Any"

will get message as follows:

E   pytest_mypy_plugins.utils.TypecheckAssertionError: Invalid output: 
E   Expected:
E     <45 (diff)
E   Actual:
E     main:12: error: No overload variant of "f" matches argument type "List[int]" (diff)
E     main:12: note:     def f(x: int) -> int       (diff)
E     main:12: note:     def f(x: str) -> str       (diff)
E     main:12: note: Possible overload variants:    (diff)
E     main:12: note: Revealed type is "Any"         (diff)
E   
E   Alignment of first line difference:
E     E: main:12: note: Revealed type is "Any"...
E     A: main:12: error: No overload variant of "f" matches argument type "List[i...
E    

while mypy will return

main.py:13: error: No overload variant of "f" matches argument type "List[int]"
main.py:13: note: Possible overload variants:
main.py:13: note:     def f(x: int) -> int
main.py:13: note:     def f(x: str) -> str
main.py:13: note: Revealed type is "Any"

Please note that

E     main:14: note: Possible overload variants:    (diff)

is misplaced compared to mypy output.

It happens, because sorting key includes actual error message:

def extract_parts_as_tuple(line: str) -> Tuple[str, int, str]:

so sort is not stable within (fname, line_number).

Environment:

  • Python: 3.9.7
  • pytest-mypy-plugins: 1.9.1
  • mypy: 0.910
@sobolevn sobolevn added the bug Something isn't working label Oct 7, 2021
zero323 added a commit to zero323/pytest-mypy-plugins that referenced this issue Oct 9, 2021
Currently, sorted_by_file_and_line uses `(filename, line, content)`.
This means it is not stable within `(filename, line)` and can
incorrectly reorder multiline outputs

Closes typeddjango#66
sobolevn pushed a commit that referenced this issue Oct 9, 2021
Currently, sorted_by_file_and_line uses `(filename, line, content)`.
This means it is not stable within `(filename, line)` and can
incorrectly reorder multiline outputs

Closes #66
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging a pull request may close this issue.

2 participants