-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Explicit Variables Warning Issue #18927
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
Comments
Hi! What warning are you seeing? Can you provide a self-contained example that reproduces the problem?
As mentioned in the other issue, coverage and mypy are unrelated tools. If both tools are raising issues for the same code, then it's likely that there's an issue with the code that's preventing it from being analyzed as you expect. There isn't enough information here to tell what that may be. |
You should be able to hover over the line to see the |
I usually don't do this much of digging into issues lacking so many details, but let's try. First of all, please don't post images of code or, if you do, accompany them with a copy-able text of your actual code. Now, either this issue is valid or from typing import Any
def fn(*objects: Any) -> None:
print(*objects, sep='\n')
fn("") Running mypy foo.py --html-report ./html Produces a report with two lines annotated as having an explicit Any - Or, as a probably more readable, the following XML report (formatted by me, from <?xml-stylesheet type="text/xsl" href="../mypy-html.xslt"?>
<mypy-report-file name="foo.py" module="foo">
<line any_info="No Anys on this line!"
content="from typing import Any"
number="1"
precision="precise" />
<line any_info="No Anys on this line!" content="" number="2" precision="empty" />
<line any_info="Any Types on this line: Explicit (x1)"
content="def fn(*objects: Any) -> None: "
number="3"
precision="any" />
<line any_info="Any Types on this line: Explicit (x1)"
content=" print(*objects, sep='\n')"
number="4"
precision="imprecise" />
<line any_info="No Anys on this line!" content="" number="5" precision="empty" />
<line any_info="Any Types on this line: Explicit (x1)"
content="fn("")"
number="6"
precision="any" />
<line any_info="No Anys on this line!" content="" number="7" precision="empty" />
</mypy-report-file> It's a repro because |
Sorry for being unclear, yes your reproduction seems to be what I faced |
Describe the bug
Coverage shows me explicit warning when being used with mypy on this:
console: Console = Console()
I don't see the problem with having an explicit type set
Why does it warn against this, can I disable it globally
Also, doing console = Console() doesn't seem to solve the problem as well
To Reproduce
How can we reproduce the problem? Please be specific. Don't link to a failing CI job. Answer the questions be
Expected behavior
A clear and concise description of what you expected to happen.
Additional context
Add any other context about the problem here.
Python 3.13
Mypy and Coverage
mypy src --html-report test
(Or any report)
Same result when I do coverage run mypy src
For reference I've opened a similar issue in the pycoverage repository and they told me it might be a mypy thing
nedbat/coveragepy#1947
The text was updated successfully, but these errors were encountered: