-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for
@type_check_only
decorator. This addresses #5810.
- Loading branch information
1 parent
1a34728
commit bf40d4c
Showing
9 changed files
with
155 additions
and
41 deletions.
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
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
40 changes: 40 additions & 0 deletions
40
packages/pyright-internal/src/tests/samples/typeCheckOnly1.py
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,40 @@ | ||
# This sample tests the reporting of a function or class decorated with | ||
# @type_check_only when used in a value expression. | ||
|
||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING, type_check_only | ||
|
||
if TYPE_CHECKING: | ||
from typing import _TypedDict | ||
|
||
a1: function | ||
a2: _TypedDict | ||
|
||
# This should generate an error. | ||
v1 = function | ||
|
||
# This should generate an error. | ||
v2 = isinstance(1, ellipsis) | ||
|
||
# This should generate an error. | ||
v3 = _TypedDict | ||
|
||
|
||
if TYPE_CHECKING: | ||
|
||
class ClassA: | ||
@type_check_only | ||
def method1(self): | ||
pass | ||
|
||
@type_check_only | ||
def func1() -> None: | ||
... | ||
|
||
|
||
# This should generate an error. | ||
ClassA().method1() | ||
|
||
# This should generate an error. | ||
func1() |
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