mypy-vscode icon indicating copy to clipboard operation
mypy-vscode copied to clipboard

Use a specific working directory to run `dmypy` in

Open utybo opened this issue 11 months ago • 6 comments

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)

utybo avatar Mar 18 '24 10:03 utybo

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?

matangover avatar Mar 18 '24 11:03 matangover

Sure! I've made a repro repository here. Instructions are in the README, let me know if you need something else 😄

utybo avatar Mar 23 '24 21:03 utybo

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.

matangover avatar Jun 03 '24 18:06 matangover

what about letting mypy look in any subdirectory?:

"mypy-type-checker.cwd": "${workspaceFolder}/*", "mypy-type-checker.reportingScope": "workspace", "mypy-type-checker.preferDaemon": true

evbo avatar Aug 02 '24 18:08 evbo

@evbo, your comment doesn't seem related to this repo. It is related to Microsoft's mypy extension.

matangover avatar Aug 10 '24 19:08 matangover

oh sorry, well it works too though :)

evbo avatar Aug 11 '24 23:08 evbo