mypy-vscode
mypy-vscode copied to clipboard
Use a specific working directory to run `dmypy` in
I'm working on a monorepo where all Python files, including the mypy.ini
, are in a specific subfolder (e.g. mypythonstuff
).
While I can use mypy.targets
and mypy.configFile
options to select the subfolder in question, I don't think it's working: it seems that the mypy.ini's package-specific settings are completely ignored (maybe because mypy considers the full path to these packages to be mypythonstuff.foo.bar
instead of foo.bar
🤔 )
An easy workaround would be to just open the mypythonstuff
folder in a separate VS Code window, or as a workspace folder, but that is somewhat more annoying than just being able to set dmypy's current working directory.
(this is similar to #82, but for a single folder)
Thanks for the report. I could definitely add an option for the working directory. Can you give me minimal instructions how to reproduce your issue with mypy.ini not working properly?
Sure! I've made a repro repository here. Instructions are in the README, let me know if you need something else 😄
Thanks for making the nice reproduction repo! and sorry for the delay... I tested your repo. You're right with your interpretation. The exclude rules in mypy.ini are being interpreted relative to mypy's cwd, and not relative to the location of mypy.ini. Thus, the solution for your special use-case is like you requested, to set the working directory. This is not a difficult feature to add.
what about letting mypy look in any subdirectory?:
"mypy-type-checker.cwd": "${workspaceFolder}/*", "mypy-type-checker.reportingScope": "workspace", "mypy-type-checker.preferDaemon": true
@evbo, your comment doesn't seem related to this repo. It is related to Microsoft's mypy extension.
oh sorry, well it works too though :)