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
Test that snippet passes #63
Comments
@0x143 can you try the same with empty Docs: https://github.com/typeddjango/pytest-mypy-plugins#3-longer-type-expectations |
Thank you for your answer @sobolevn. I tried putting an empty I've seen that |
It might be an issue with django-stubs, can you please investigate? |
I'll be happy to, but I am not exactly sure what I am looking for. I've done some basic tests to see if So I am really not sure what I am looking for here (any config options maybe?) Sorry for naive questions and thank you for your support and patience @sobolevn! |
@0x143 ok, then we need to find which |
I don't use any custom mypy configuration @sobolevn, but I don't think that import following is an issue here. To better illustrate the problem, here is a minimal repo that shows the issue. As you see, it isnot limited to imports ‒ incorrect calls seem to be ignored as well. Also, mypy called directly with the same (empty config) on equivalent source files, detects the problems. |
Ok, this a pretty serious bug. I don't know how long this was hidding! Can you please fix it? PRs are more than welcome! |
I'll try to investigate this further and see if I can figure out the fix. Thanks again for all your responses @sobolevn! |
It should be enough to modify index dd8db72..3448675 100644
--- a/pytest_mypy_plugins/utils.py
+++ b/pytest_mypy_plugins/utils.py
@@ -230,7 +230,7 @@ def assert_expected_matched_actual(expected: List[OutputMatcher], actual: List[s
actual = remove_common_prefix(actual)
error_message = ""
- if not all(e.matches(a) for e, a in zip(expected, actual)):
+ if len(actual) != len(expected) or not all(e.matches(a) for e, a in zip(expected, actual)):
num_skip_start = _num_skipped_prefix_lines(expected, actual)
num_skip_end = _num_skipped_suffix_lines(expected, actual) It should also save some work, because we can short circuit and skip actual matching. |
One could probably refactor the whole thing to just iterate over from itertools import islice, zip_longest
stop = max(len(actual), len(expected)) - num_skip_end)
for i, (e, a) in enumerate(islice(zip_longest(expected, actual)), num_skip_start, stop)):
if a is None or e is None or not e.matches(a):
... # Report failure This way, |
This PR: - Refactors assert_expected_matched_actual function to avoid repeated matching between expected and actual output - Fixes typeddjango#63, typeddjango#64
* Refactor and fix assert_expected_matched_actual This PR: - Refactors assert_expected_matched_actual function to avoid repeated matching between expected and actual output - Fixes #63, #64 * Reorder imports * Add test file * Add back leading or trainling ... in case of matching input * Fix and group leading / trailing ... logic * Update test-expect-fail.yaml file * Update tests * Express error_message prefix in terms of actual and expected * Drop data test and add unit tests * Add return type annotation * Make exact match on the error_message * Reformat utils.py
In mypy internal testing suite I can omit output to indicate that I expect snippet to pass
This is very useful for basics checks.
However, I cannot get similar behaviour here. If I create a package
with
and
tests run without errors (
pytest-mypy-plugins==1.9.1
,mypy==0.910
) despite incorrect importfoo
.I have to put some output check
to get an exception.
I also tried using empty out block
but it still silently ignores the broken import.
The text was updated successfully, but these errors were encountered: