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

Add --mypy-config option #110

Closed
pbelskiy opened this issue Oct 22, 2020 · 4 comments · Fixed by #125
Closed

Add --mypy-config option #110

pbelskiy opened this issue Oct 22, 2020 · 4 comments · Fixed by #125

Comments

@pbelskiy
Copy link

Hello! I have not found how to pass path to mypy config?

I want something like: pytest --mypy --mypy-config tox.ini

It's because mypy isn't read config from tox.

@dmtucker
Copy link
Collaborator

Hey there 👋 I would recommend implementing a pytest_configure hook in conftest.py for this:

def pytest_configure(config):
    plugin = config.pluginmanager.getplugin("mypy")
    plugin.mypy_argv.extend(["--config-file", "tox.ini"])

@ngie-eign
Copy link

ngie-eign commented Feb 17, 2021

@dmtucker: doing this would require implementing it in every conftest.py file, which would degrade the usability for end-users and increase unnecessary repetition in the source code, across multiple projects (it also makes the configuration file specification more opaque to folks debugging what is going on, potentially).

@dmtucker
Copy link
Collaborator

in every conftest.py file

conftest.py files should cascade (i.e. tests/conftest.py should apply to tests/foo/* and tests/bar/*, etc).

Maybe I'm not understanding the issue? 🤔

across multiple projects

Most projects won't need this, and I really don't want to get into the business of mirroring mypy's CLI.
Moreover, I don't see how this solves your problem... You would still need to change the pytest invocation (e.g. in tox.ini) for every project to use --mypy-config.

If you want to be able to control how multiple pytest projects run in a single place, I would suggest making an installable plugin and adding it as a dependency to each of your projects. Then, you would only need to change that plugin and publish it in order to affect all your projects.

@Mohsin-Ul-Islam
Copy link
Contributor

@dmtucker I am using Bazel to run pytest across my python libraries and services in a monorepo. Since Bazel builds everything in a separate environment I cannot pass the config file path to the plugin in conftest.py, I have to define the path in Bazel's BUILD file. But the only way to pass config file path in Bazel's BUILD file is via flag to this plugin.

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

Successfully merging a pull request may close this issue.

4 participants