-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #106 from seequent/type-hints
Fixes type hint, permits & handles singledispatchmethod
- Loading branch information
Showing
6 changed files
with
56 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,3 +96,4 @@ ENV/ | |
|
||
# build output | ||
dist/ | ||
/.pypirc |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from functools import singledispatchmethod | ||
from typing import Any | ||
import unittest | ||
|
||
import pure_interface | ||
|
||
|
||
class TestSingleDispatch(unittest.TestCase): | ||
def test_single_dispatch_allowed(self): | ||
class IPerson(pure_interface.Interface): | ||
@singledispatchmethod | ||
def greet(self, other_person: Any) -> str: | ||
pass | ||
|
||
self.assertSetEqual(pure_interface.get_interface_method_names(IPerson), {'greet'}) | ||
|
||
def test_single_dispatch_checked(self): | ||
class IPerson(pure_interface.Interface): | ||
def greet(self) -> str: | ||
pass | ||
|
||
pure_interface.set_is_development(True) | ||
with self.assertRaises(pure_interface.InterfaceError): | ||
class Person(IPerson): | ||
@singledispatchmethod | ||
def greet(self, other_person: Any) -> str: | ||
pass | ||
|