Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a specific working directory to run dmypy in #89

Open
utybo opened this issue Mar 18, 2024 · 6 comments
Open

Use a specific working directory to run dmypy in #89

utybo opened this issue Mar 18, 2024 · 6 comments

Comments

@utybo
Copy link

utybo commented Mar 18, 2024

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)

@matangover
Copy link
Owner

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?

@utybo
Copy link
Author

utybo commented Mar 23, 2024

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

@matangover
Copy link
Owner

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.

@evbo
Copy link

evbo commented Aug 2, 2024

what about letting mypy look in any subdirectory?:

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

@matangover
Copy link
Owner

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

@evbo
Copy link

evbo commented Aug 11, 2024

oh sorry, well it works too though :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants