Open Delgan opened 10 months ago
Thanks a lot!
@sobolevn I updated the PR according to your comments. :+1:
Two remarks waiting for your opinion:
mypy-config
table to config-mypy
for consistency with the existing inline field.join_ini_configs()
but I don't know what are your preferences regarding the assert_file_contents()
utils function (should it be duplicated, or what is the common file where I should move it).
Hi!
This is a proposal to fix #133.
This offers a way to use Mypy configuration specific to tests without needing the
--mypy-pyproject-toml-file
command line argument. Instead, users can define a[tool.pytest-mypy-plugins.mypy-config]
table in their repository'spyproject.toml
file.This approach addresses two issues:
pytest
can be invoked from any location (this is not possible when--mypy-pyproject-toml-file
is specified via theaddopts
configuration, as paths are resolved relative to the current working directory).The order of precedence for Mypy configuration is as follows, with each subsequent option taking precedence over the previous ones if it exists:
[tool.pytest-mypy-plugins.mypy-config]
in the rootpyproject.toml
as default.--mypy-pyproject-toml-file
or--mypy-ini-file
if provided.config_mypy
section in a test if present.I hope this process isn't too convoluted. Please let me know if you prefer a different approach. I made slight modifications to the
join_toml_configs()
function to implement the rules mentioned above. Additionally, I can add more unit tests if necessary.