-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
391d030
commit a9751e4
Showing
4 changed files
with
49 additions
and
4 deletions.
There are no files selected for viewing
Empty file.
19 changes: 19 additions & 0 deletions
19
tests/test_past_issues/test_8_non_protocol_member/input.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,19 @@ | ||
from typing import Generic, TypeVar | ||
|
||
from typing_protocol_intersection import ProtocolIntersection | ||
|
||
|
||
class NotProtocol: | ||
pass | ||
|
||
|
||
T = TypeVar("T") | ||
|
||
|
||
class Noop(Generic[T]): | ||
@classmethod | ||
def noop(cls, value: T) -> ProtocolIntersection[T]: | ||
return value | ||
|
||
|
||
np = Noop[NotProtocol].noop(NotProtocol()) |
17 changes: 17 additions & 0 deletions
17
tests/test_past_issues/test_8_non_protocol_member/test_8_non_protocol_member.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,17 @@ | ||
""" | ||
ref: https://github.com/klausweiss/typing-protocol-intersection/issues/8 | ||
""" | ||
from pathlib import Path | ||
|
||
HERE = Path(__file__).parent | ||
|
||
|
||
def test_8_non_protocol_member(run_mypy): | ||
# given | ||
input_file = HERE / "input.py" | ||
# when | ||
stdout, _stderr = run_mypy(input_file, no_incremental=False) | ||
# then no error | ||
assert not stdout.startswith("Success") | ||
assert "error:" in stdout | ||
assert "Only Protocols can be used in ProtocolIntersection" in stdout |
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