Default "--soft-error-limit" behavior causes tons of headache for mypy newbies with large code bases #14915
Labels
bug
mypy got something wrong
good-first-issue
topic-configuration
Configuration files and flags
topic-usability
Uh oh!
There was an error while loading. Please reload this page.
Bug Report
While not strictly a bug, I would argue that there is a "bug" in the logic behind the decision to add a default
--soft-error-limit
of200
(added in #10579). The idea was to make it easier to identify missing stubs as the root cause for a flood of errors, especially useful when settings are strict. However, I would assume that strict settings are typically used bymypy
experts while newbies would typically start with the default settings and gradually work their way up to strict settings (if at all). So while the default values of the strictness settings favor newbies, I think the default behavior of--soft-error-limits
inconsistently (and unhelpfully) favors experts at the expense of newbies.Furthermore, this error limit applies to all errors, regardless of whether they are caused by missing stubs or not. This leads to very confusing error outputs for large code bases that are in the process of being typed by
mypy
newbies. Since Python typing already is a complicated heap of (insert word here), even for devs with tons of experience in non-typed Python, I would think it is of importance for themypy
project to try to lower the threshold for adoption by newbies as much as possible. However, the default setting of--soft-error-limit
does the opposite: It is counterintuitive thatmypy
by default has an error limit that silences errors.The default behavior is especially confusing when
mypy
is used in the context of an IDE such as PyCharm (also mentioned by @ilevkivskyi in this comment #10579 (comment)). In this case, the error messages are filtered by module name so that the note(Skipping most remaining errors due to unresolved imports or missing stubs; fix these first)
will appear in a random module and most probably not be read by the user. In my personal experience, trying to debug the discrepancy between the inlinemypy
errors and the lack of the same errors in the global view made me in the end want to pull out my last few remaining strands of hair rather than continue the hunt. This particular discrepancy was one of the worst issues I have ever tried to debug, as there were no patterns to which errors were silenced. Debugging, on the other hand, is typically done by trying to find the pattern that cause the bug to appear:To Reproduce
As a
mypy
newbie, runmypy
on a large code base that have been partially or fully typed, but where detailed fixing ofmypy
errors have been postponed due to the priority of developing actual features. To increase the pain level to the maximum, do this in PyCharm or other IDE where errors are filtered by module. Then:mypy
library--soft-error-limit=-1
and witness the total number of errors multiplyExpected Behavior
--soft-error-limit
is set, a note should be added at the very end of the error output that also mentions the actual config/command-line setting to tweaksoft_error_limit
should be added that corresponds to the command-line flagverbosity=1
should, for each module, log whether any errors were silenced due to the settingActual Behavior
No more than 200 errors are reported (in my case only 139 errors and 41 notes were reported, for some reason). Errors are randomly silenced in global runs for no apparent reason and with no easily noticed error messages. Reading the log at
verbosity=1
gives no clue to the reason why errors are silenced.Your Environment
--show-column-numbers --follow-imports silent
(default for PyCharmmypy
plugin)mypy.ini
(and other config files):mypy_path = "src:tests"
The text was updated successfully, but these errors were encountered: