You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bug Report
The LineCountReporter (mypy.report.LineCountReporter) counts a function as typed even if one of the arguments is typed or it only has a return value (which I would refer as partially typed). Ideally, I would want a report of functions which are fully typed (and not partially) to gauge correctly how well-typed the codebase is.
To Reproduce
Create a python file test.py
from __future__ importannotationsdeffoo(a, b: str) ->str:
return"bar"
Create an ini file .mypy.ini
[mypy]files = test.py
linecount_report = .
Now run mypy --config-file .mypy.ini
And cat linecount.txt
Expected Behavior
I would expect the line count report to look like
<don't care> <don't care> 0 1 total
Actual Behavior
<don't care> <don't care> 1 1 total
Your Environment
Mypy version used: 1.12.0
Mypy command-line flags: --config-file
Mypy configuration options from mypy.ini (and other config files):
[mypy]files = test.py
linecount_report = .
Python version used: 3.9.6
I believe this is happening because while visiting each function we are just checking for the existence of type attribute in its Function Definition
I would expect this logic to be similar to the function def checker mypy.checker.TypeChecker.check_func_def; this method particularly mypy.checker.TypeChecker.check_for_missing_annotations which is actually a more elaborate check and goes over each argument to check the existence of its type
I am happy to raise a PR for this, but I need help with a couple of things
Was this an intentional choice?
If yes, can we consider adding a flag or reusing the disallow_incomplete_defs flag for determining if the function should be counted as typed or not in the report
Even if no, this doesn't look like a backward compatible change, looking for thoughts around this
One of the ways to not make this a breaking change would be to use a new flag which is specific to linecount, in which case, of course, this is a feature request and not a bug
The text was updated successfully, but these errors were encountered:
Bug Report
The LineCountReporter (
mypy.report.LineCountReporter
) counts a function as typed even if one of the arguments is typed or it only has a return value (which I would refer as partially typed). Ideally, I would want a report of functions which are fully typed (and not partially) to gauge correctly how well-typed the codebase is.To Reproduce
Create a python file
test.py
Create an ini file
.mypy.ini
Now run
mypy --config-file .mypy.ini
And
cat linecount.txt
Expected Behavior
I would expect the line count report to look like
Actual Behavior
Your Environment
mypy.ini
(and other config files):I believe this is happening because while visiting each function we are just checking for the existence of
type
attribute in its Function DefinitionI would expect this logic to be similar to the function def checker
mypy.checker.TypeChecker.check_func_def
; this method particularlymypy.checker.TypeChecker.check_for_missing_annotations
which is actually a more elaborate check and goes over each argument to check the existence of its typeI am happy to raise a PR for this, but I need help with a couple of things
disallow_incomplete_defs
flag for determining if the function should be counted as typed or not in the reportThe text was updated successfully, but these errors were encountered: