python / python/mypy

api.run has empty reports when crashing early

Open
#7,534 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature priority-1-normal
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

I'm seeing a case where CLI would ouput useful messages but api.run is not. This causes https://github.com/PyCQA/prospector to think that the mypy run was successful when it wasn't (granted, prospector should look at exit_status).

mypy.ini

[mypy]
plugins = mypy_django_plugin.main
warn_return_any = True
warn_unused_configs = True
disallow_subclassing_any = True
disallow_any_generics = True
disallow_untyped_calls = True
disallow_untyped_defs = True
disallow_incomplete_defs = True
check_untyped_defs = True
disallow_untyped_decorators = True
no_implicit_optional = True
warn_redundant_casts = True
warn_unused_ignores = True
mypy_path = stubs

[mypy.plugins.django-stubs]
django_settings_module = "imake.settings"

Output of CLI

env PYTHONPATH=(pwd) mypy core/shortcuts.py
oscar_forks/catalogue/models.py:6: error: Module 'oscar.apps.catalogue.abstract_models' has no attribute 'AbstractCategory'
oscar_forks/catalogue/models.py:21: error: Class cannot subclass 'AbstractCategory' (has type 'Any')
stubs/oscar/apps/catalogue/abstract_models.pyi:3: error: INTERNAL ERROR -- Please try using mypy master on Github:
https://mypy.rtfd.io/en/latest/common_issues.html#using-a-development-mypy-build
If this issue continues with mypy master, please report a bug at https://github.com/python/mypy/issues
version: 0.720
stubs/oscar/apps/catalogue/abstract_models.pyi:3: : note: please use --show-traceback to print a traceback when reporting a bug

Return value of api.run

('', '', 2)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the api.run entry point and compare its behavior with the CLI using the provided mypy.ini configuration and mypy command. Reproduce the early crash, then verify that api.run exposes the same diagnostic output as the CLI while preserving the exit status.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.