Repository navigation
Closed
Labels
bugmypy got something wrongmypy got something wrongtopic-configurationConfiguration files and flagsConfiguration files and flagstopic-daemondmypydmypy
Description
Bug Report
dmypy ignores flags and config file
#11396 (comment)
@sehyun-hwang This seems like a dmypy bug. It seems that dmypy ignores cli flags or config file flags in certain cases.
Here's a file structure:
$ tree . . ├── a.py ├── b.py └── mypy.iniAnd
mypy.inicontains the following:[mypy] strict = True
a.pyandb.pyboth contain:def foo(): passThis way
mypy a.pywon't show errors butmypy --strict a.pywill. When alternating betweendmypy check a.pyanddmypy check b.py, at some pointdmypystops showing strict output. For the same reason it might be forgetting the--outputflag being set as well.
To Reproduce
With the file structure above,
Expected Behavior
--strict flag and other arguments should be applied.
Actual Behavior
--strict flag of the last command gets ignored.
root@f24a1f5cf5c6:/mnt# dmypy run -- --strict foo.py
Daemon started
foo.py:1: error: Function is missing a return type annotation
foo.py:1: note: Use "-> None" if function does not return a value
Found 1 error in 1 file (checked 25 source files)
root@f24a1f5cf5c6:/mnt# dmypy run -- --strict bar.py
bar.py:1: error: Function is missing a return type annotation
bar.py:1: note: Use "-> None" if function does not return a value
Found 1 error in 1 file (checked 1 source file)
root@f24a1f5cf5c6:/mnt# dmypy run -- --strict foo.py
Success: no issues found in 1 source file
Your Environment
- Mypy version used: Latest version hosted in pip
- Mypy command-line flags:
--strict - Mypy configuration options from
mypy.ini(and other config files):
strict = trueor no config file - Python version used: 3.10
- Operating system and version: Latest Python Docker image
Reacted by Alexandre DuBreuil, adam-grant-hendry and CoolCat467
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-configurationConfiguration files and flagsConfiguration files and flagstopic-daemondmypydmypy
Activity
eliotwrobson commentedon Jun 9, 2022
Is there a workaround for this issue? I'd really like to use dmypy on a project I'm working on (as it will speed up our CI job considerably compared to mypy), but I need to be able to set options in a config file.
dubreuia commentedon Jun 15, 2022
We have the same problem, first execution
dmypy run -- --config-file mypy.iniuses the--config-file, but second run doesn'tdubreuia commentedon Jun 15, 2022
Maybe a bug in the arg parsing: https://github.com/python/mypy/blob/master/mypy/dmypy/client.py#L256
felixmeziere commentedon Jul 1, 2022
I have the same issue! Really a bummer in terms of productivity :/
dubreuia commentedon Jul 20, 2022
Hello all 👋 ,
I've made some progress in understanding the problem. For us the problem is that between two git pulls the daemon checks only the changed files (I think that's normal behavior), but outputs lots of errors that there wasn't in the first run (not sure why, that's the problem) or errors that are not present when running
mypyaloneHow to reproduce (for me)
dmypy run -- --config-file mypy.iniSuccess: no issues found in 4051 source filesgit pullto get changesdmypy recheckFound 102 errors in 16 files (checked 4051 source files)mypyalone doesn't output errors)dmypy run -- --config-file mypy.iniagain)The problem
dmypyfails with errors that are wrongdmypydoesn't use the context from the previous run for type informationWhat I tried
fine_grained_increment_follow_imports(here) which is called on the second run and subsequentdmypyto use all the files by usingdmypy recheck --update <ALL THE ROOT FOLDERS>IsADirectoryError: [Errno 21] Is a directory: 'apps'(doesn't support folders)I'm out of ideas, hope it helps one of you to have a look
Update
dmypy recheck --update <LIST OF FILES>anddmypy check <LIST OF FILES>and it doesn't helpdubreuia commentedon Aug 4, 2022
Latest update
In the hopes this will help someone days of trial and errors and debugging: we found a workaround
The problem described above here (
dmypysecond run outputs errors that aren't present) is NOT present ifdmypyuses a pre-build fine-grained cacheSolution:
mypy --cache-fine-grained --config-file mypy.inidmypy run -- --use-fine-grained-cache --config-file mypy.inidmypyhas no issues, even whengit pulland stuff)felixmeziere commentedon Oct 5, 2022
Same problem here, really a problem as the errors in vscode are different than when running mypy
Fix re-added file with errors in mypy daemon (#15440)