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

Conformance tests: Fix pyright scoring for protocols_variance #1702

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions conformance/results/pyright/protocols_definition.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,4 @@ protocols_definition.py:341:22 - error: Expression of type "Concrete6_Bad3" cann
conformance_automated = "Pass"
errors_diff = """
"""
ignore_errors = ["Static methods should not take a \"self\" or \"cls\" parameter"]
9 changes: 1 addition & 8 deletions conformance/results/pyright/protocols_variance.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ protocols_variance.py:71:7 - warning: Type variable "T1_contra" used in generic
protocols_variance.py:72:21 - error: Contravariant type variable cannot be used in return type (reportGeneralTypeIssues)
protocols_variance.py:104:7 - warning: Type variable "T1" used in generic protocol "Protocol12" should be covariant (reportInvalidTypeVarUse)
"""
conformance_automated = "Fail"
conformance_automated = "Pass"
errors_diff = """
Line 21: Expected 1 errors
Line 40: Expected 1 errors
Line 56: Expected 1 errors
Line 61: Expected 1 errors
Line 66: Expected 1 errors
Line 71: Expected 1 errors
Line 104: Expected 1 errors
"""
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ qualifiers_final_decorator.py:126:5 - error: Function "func1" cannot be marked @
conformance_automated = "Pass"
errors_diff = """
"""
ignore_errors = ["reportMissingModuleSource"]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pyright (and several others) don't actually pick up the _qualifiers_final_decorator.pyi stub file. Leaving that for another day.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what you mean by "don't actually pick up the stub file". Can you elaborate? I'm seeing pyright resolve the import with the stub file when I run the test. Are you seeing something different?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I misinterpreted the pyright error; I thought it meant pyright couldn't find the file at all, but it seems like it means only that pyright couldn't find the .py file, but it picked up the .pyi correctly.

It does appear that pytype can't resolve the import (File "qualifiers_final_decorator.py", line 8, in <module>: Couldn't import pyi for '_qualifiers_final_decorator' [pyi-error]), but all other type checkers are fine. Pytype also fails this test for other reasons, so we don't need to worry about that yet.

2 changes: 1 addition & 1 deletion conformance/src/type_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def parse_errors(self, output: Sequence[str]) -> dict[int, list[str]]:
assert line.count(":") >= 3, f"Failed to parse line: {line!r}"
_, lineno, kind, _ = line.split(":", maxsplit=3)
kind = kind.split()[-1]
if kind != "error":
if kind not in ("error", "warning"):
continue
line_to_errors.setdefault(int(lineno), []).append(line)
return line_to_errors
Expand Down