Skip to content

dmypy - warn instead of failing if report generation is configured #10181

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

Merged
merged 5 commits into from
Mar 19, 2022

Conversation

natemcmaster
Copy link
Contributor

Description

Log a warning instead of failing when dmypy run is called on a project that has report generation configured via setup.cfg

Resolves #10118

Test Plan

  1. Built package locally
  2. Installed into my virtualenv
  3. Created test project with mypy.ini contents:
    [mypy]
    html_report = build/html
  4. Ran dmypy run .

Result:

dmypy run .
dmypy: ignoring report generation settings. Start/restart cannot generate reports.
Daemon started

@JelleZijlstra
Copy link
Member

Why do we even need a warning? I'd expect dmypy to simply ignore any config file settings related to reports. However, if you pass an explicit command line argument around report generation to dmypy, we should generate an error.

I might be wrong here though since I don't regularly use either the daemon or reports. Here are my assumptions:

  • the daemon doesn't know how to generate any sort of report
  • users who are interested in reports would run non-daemon mypy to generate a report occasionally, but run dmypy run more frequently in order to do type checking. Such users would want to put their report generation settings in mypy.ini.

@natemcmaster
Copy link
Contributor Author

@JelleZijlstra my usage of dmypy and reports is:

  • I want reports for CI builds which use the non-daemon mypy to help track progress towards full type annotation coverage
  • I am using dmypy because the VS Code integration with mypy and Pycharm type checker still just aren't good enough yet, so dmypy is the fastest way to quickly check type hints in my large codebase

While trying to fix this, I initially thought I would try to make a bigger change, but I found that the code which raises this warning/error doesn't know the difference between an explicit command line option and a config file option, nor does it know which dmypy subcommand is being called. Both are possible to fix with some refactoring, but figured this small tweak solved my papercut and was a good starting point for more discussion.

@JelleZijlstra JelleZijlstra merged commit 8d02b47 into python:master Mar 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Have dmypy gracefully ignore report generation settings
3 participants