Skip to content

Success message missing when reveal_type() used. #12302

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

Closed
mrolle45 opened this issue Mar 7, 2022 · 5 comments · Fixed by #12306
Closed

Success message missing when reveal_type() used. #12302

mrolle45 opened this issue Mar 7, 2022 · 5 comments · Fixed by #12306
Labels
bug mypy got something wrong

Comments

@mrolle45
Copy link

mrolle45 commented Mar 7, 2022

Bug Report

I have something like if TYPE_CHECKING: reveal_type(foo) in a module (in 5 places).
mypy finds no errors, but the line that says "success" is missing.

Here's two sets of output from mypy, first with reveal_type() in the module, and second without.

D:\Solutions\trunk\Python\Sass>mypy .
solver\common.py:299: note: Revealed type is "Any"
solver\common.py:366: note: Revealed type is "Any"
solver\common.py:521: note: Revealed type is "solver.instruct.InstrTab"
solver\common.py:522: note: Revealed type is "Any"
solver\common.py:523: note: Revealed type is "Any"

D:\Solutions\trunk\Python\Sass>mypy .
Success: no issues found in 52 source files

What I think is correct output, in the first case, is

D:\Solutions\trunk\Python\Sass>mypy .
solver\common.py:299: note: Revealed type is "Any"
solver\common.py:366: note: Revealed type is "Any"
solver\common.py:521: note: Revealed type is "solver.instruct.InstrTab"
solver\common.py:522: note: Revealed type is "Any"
solver\common.py:523: note: Revealed type is "Any"
Success: no issues found in 52 source files

Your Environment

  • Mypy version used: 0,92`
  • Python version used: 3.7
  • Operating system and version: Windows 10
@mrolle45 mrolle45 added the bug mypy got something wrong label Mar 7, 2022
@KotlinIsland
Copy link
Contributor

KotlinIsland commented Mar 8, 2022

This happens if there are only notes (notes still cause failure, but no error count) in the output:
playground https://mypy-play.net/?mypy=latest&python=3.10&gist=3d64dc19218346533773b8f84b9535fa

@mrolle45
Copy link
Author

mrolle45 commented Mar 11, 2022

I think that if there are only notes, and no errors or blockers, the return code should be success as well.

I wrote a replacement for the code in main() lines 116-131 that produces the desired return status and error summary:

    code = 0
    if messages:
        n_errors, n_files = util.count_stats(messages)
        code = 1
    if blockers: code = 2
    if options.error_summary:
        if messages and n_errors:
            summary = formatter.format_error(
                n_errors, n_files, len(sources), blockers=blockers,
                use_color=options.color_output
            )
            stdout.write(summary + '\n')
        if code == 0:
            stdout.write(formatter.format_success(len(sources), options.color_output) + '\n')
        stdout.flush()

You can use this code.

@KotlinIsland
Copy link
Contributor

KotlinIsland commented Mar 11, 2022

@97littleleaf11 Here is a workaround:

from typing import *

error: Literal[": error:"]
reveal_type(error)
> mypy main.py
main.py:4: note: Revealed type is "Literal[': error:']"
Found 1 error in 1 file (checked 1 source file)

https://mypy-play.net/?mypy=latest&python=3.10&gist=50bd436765ad217d1cc28568221c7c5f

@97littleleaf11
Copy link
Collaborator

@KotlinIsland I think we can leave this corner case behind.

@KotlinIsland
Copy link
Contributor

What I meant was, it is a workaround to the issue in the OP 😂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants