python / python/mypy

The execution results of dmypy are not as expected

Open
#17,797 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug topic-daemon
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

Operation steps

  1. I start a daemon server
    command = [
        'dmypy', '--status-file', status_file_name, 'start', '--log-file', mypy_server_log_name,
        '--', '--show-column-numbers', '--show-error-end'
    ]
    process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    out, err = process.communicate()
  1. use command line to check
dmypy --status-file xxxx.json check -v xxx.py

It can output the correct result

  1. use python to write file,and use command line to check again
with open(path, 'w') as file:
    file.write(content)

It can not output any issue,like:

Success: no issues found in 1 source file
err                     : 
out                     : Success: no issues found in 1 source file\n
platform                :     darwin
python_version          :       3_11
roundtrip_time          :      1.148
stats                   : {'find_module_time': 0.006188869476318359, 'find_module_calls': 673, 'update_isolated_time': 0.0071163177490234375, 'propagate_time': 1.1365551948547363, 'find_changes_time': 0.00043392181396484375, 'fg_update_time': 6.198883056640625e-06, 'refresh_suppressed_time': 0.0006737709045410156, 'find_added_supressed_time': 0.0018012523651123047, 'cleanup_time': 1.1443119049072266}
status   
  1. BUT if I use mypy instead of dmypy,It can output correct result:
mypy xxx.py

Found 8 errors in 6 files (checked 1 source file)
err                     : 
out                     : c8f34f1c-8173-4437-b07f-8d7f8c7f7210/FLO ... 1725 more characters
platform                :     darwin
python_version          :       3_11
roundtrip_time          :      0.160
stats                   : {'validate_meta_time': 8.96453857421875e-05, 'files_parsed': 34, 'modules_parsed': 22, 'stubs_parsed': 12, 'parse_time': 0.01146078109741211, 'find_module_time': 0.01342916488647461, 'find_module_calls': 3688, 'semanal_time': 0.018131256103515625, 'typecheck_time': 0.014755964279174805, 'finish_passes_time': 0.007950305938720703, 'load_fg_deps_time': 1.5020370483398438e-05, 'update_isolated_time': 0.1284799575805664, 'propagate_time': 0.02331995964050293, 'find_changes_time': 0.0006420612335205078, 'fg_update_time': 0.1564321517944336, 'refresh_suppressed_time': 0.0005068778991699219, 'find_added_supressed_time': 0.0013458728790283203, 'cleanup_time': 0.0001461505889892578}
status                  :          1
  1. If I manually change the python file slightly,the dmypy can ouput correct result again

Your Environment

  • Mypy version used: 1.10.1

Is there anything special about the caching logic of this dmypy? Will all information be lost if the file is regenerated?

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

Reproduce the reported sequence with dmypy start, dmypy check, the generated Python file, and the status file, then compare it with mypy on version 1.10.1. Start by investigating dmypy's incremental caching behavior and whether rewriting the file invalidates its cached state. Done means dmypy reports the same type errors as mypy after the file is regenerated.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.