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

reportUnusedCallResult special casing for reveal_type doesn't work when aliased #964

Open
abelcheung opened this issue Dec 22, 2024 · 3 comments
Labels
type checking / linting issues relating to existing diagnostic rules or proposals for new diagnostic rules

Comments

@abelcheung
Copy link

Minimal example:

from typing import reveal_type as rt

def test_inferred() -> None:
    x = 1
    rt(x)

The reportUnusedCallResult rule is triggered in this case, with exit code = 1. However, if I don't rename reveal_type(), then the rule is not triggered, and exit code = 0.

Actually pyright has same problem if I forcefully add {"reportUnusedCallResult":"warning"} to pyrightconfig.json. But since basedpyright opt to turn on this rule by default but not pyright, do you think if it worths fixing in basedpyright?

@abelcheung
Copy link
Author

Hmm, on second thought, it should have been affected by the rule as well, but given how people commonly use reveal_type(), only this func got special treatment. What's your opinion here? I have disabled this rule locally in my tests, so it's fine either way.

@DetachHead
Copy link
Owner

DetachHead commented Dec 22, 2024

yeah reveal_type is special cased here. related issues: #315 #544

@DetachHead DetachHead added the type checking / linting issues relating to existing diagnostic rules or proposals for new diagnostic rules label Dec 23, 2024
@KotlinIsland KotlinIsland changed the title reportUnusedCallResult may trigger or not, depending on function name reportUnusedCallResult special casing for reveal_type doesn't work when aliased Jan 1, 2025
@KotlinIsland
Copy link
Collaborator

also this:

def reveal_type() -> int:
    return 1

reveal_type()  # no error

def foo() -> int:
    return 1

foo()  # error

playground

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type checking / linting issues relating to existing diagnostic rules or proposals for new diagnostic rules
Projects
None yet
Development

No branches or pull requests

3 participants