Skip to content

Commit ab5dea2

Browse files
authored
Make VALID and INVALID covariant (#541)
By using `Sequence`, these become covariant. Previously, doing something like: ``` VALID = [ ValidTestCase("..."), ValidTestCase("..."), ] ``` would be a type error in `pyre`, because `pyre` would infer this to be a `list[ValidTestCase]` which is *not* a subclass of `list[str | ValidTestCase]`. By making these `Sequence`s (and thus immutable), we can avoid the requirement of having explicit type annotations everywhere for this.
1 parent e5b6e52 commit ab5dea2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/fixit/rule.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ class LintRule(BatchableCSTVisitor):
7676
__ https://peps.python.org/pep-0440/#version-specifiers
7777
"""
7878

79-
VALID: ClassVar[List[Union[str, Valid]]]
79+
VALID: ClassVar[Sequence[Union[str, Valid]]]
8080
"Test cases that should produce no errors/reports"
8181

82-
INVALID: ClassVar[List[Union[str, Invalid]]]
82+
INVALID: ClassVar[Sequence[Union[str, Invalid]]]
8383
"Test cases that are expected to produce errors, with optional replacements"
8484

8585
AUTOFIX = False # set by __subclass_init__

0 commit comments

Comments
 (0)