forked from microsoft/pyright
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added error reporting for instance and class variables within methods…
… declared in a Protocol class. PEP 544 indicates that these should be flagged as an error.
- Loading branch information
1 parent
bc2c8d4
commit 7afbbca
Showing
4 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# This sample tests that instance and class variables | ||
# assigned within a Protocol method are flagged as errors. | ||
|
||
from typing import List, Protocol | ||
|
||
class Template(Protocol): | ||
def method(self) -> None: | ||
# This should be an error | ||
self.temp: List[int] = [] | ||
|
||
@classmethod | ||
def cls_method(cls) -> None: | ||
# This should be an error | ||
cls.test2 = 3 | ||
|
||
|