-
Notifications
You must be signed in to change notification settings - Fork 30
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
mypy can't discover pytest.lazy_fixture under pytest 6 #51
Comments
importing it directly |
This change will add stubs for pytest-lazyfixture. It is particual useful for projects which type their tests and use pytest-lazyfixture. The included functions and classes are the scope which can be considered documented by the module. Any other function is related to pytest hook implementations and are normally not called by an user. Please note, that if a user uses 'pytest.lazy_fixture' these stubs will not work. As recommneded in TvoroG/pytest-lazy-fixture#51 the package needs to imported directly.
This change will add stubs for pytest-lazyfixture. It is particual useful for projects which type their tests and use pytest-lazyfixture. The included functions and classes are the scope which can be considered documented by the module. Any other function is related to pytest hook implementations and are normally not called by an user. Please note, that if a user uses 'pytest.lazy_fixture' these stubs will not work. As recommneded in TvoroG/pytest-lazy-fixture#51 the package needs to imported directly. Co-authored-by: Akuli <[email protected]>
tests/common/test_models.py: It seems that without importing from pytest_lazyfixture, lazy_fixture types are not properly detected: TvoroG/pytest-lazy-fixture#51
tests/common/test_models.py: It seems that without importing from pytest_lazyfixture, lazy_fixture types are not properly detected: TvoroG/pytest-lazy-fixture#51
The pytest devs consider monkey-patching invalid:
Hence, the solution (and not just a workaround) is this:
This is also the way it's documented in the |
If you have a test suite that uses
pytest.lazy_fixture
, and you're using pytest 6.0.0+, and you run mypy over your test suite, mypy complains with the error:The test suite itself passes without any problems; it is only the type checking of mypy that fails.
This problem does not exist on pytest 5.4.3 or earlier.
I presume something has changed in the plugin registration process that prevents mypy from seeing the lazy_fixture attribute.
The text was updated successfully, but these errors were encountered: