-
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.
Browse files
Browse the repository at this point in the history
* Defer evaluation of a UserObject schema entirely to resolve #55 * Bump version to 0.2.3
- Loading branch information
Showing
7 changed files
with
126 additions
and
53 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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from typing import List | ||
|
||
from abc import ABC, abstractmethod | ||
|
||
from wysdom import UserObject, UserProperty, SchemaArray, SchemaConst | ||
from wysdom.mixins import RegistersSubclasses | ||
|
||
|
||
class Pet(UserObject, RegistersSubclasses, ABC): | ||
pet_type: str = UserProperty(str) | ||
name: str = UserProperty(str) | ||
|
||
@abstractmethod | ||
def speak(self): | ||
pass | ||
|
||
|
||
class Person(UserObject): | ||
first_name: str = UserProperty(str) | ||
last_name: str = UserProperty(str) | ||
pets: List[Pet] = UserProperty(SchemaArray(Pet)) | ||
|
||
|
||
class Dog(Pet): | ||
|
||
def speak(self): | ||
return f"{self.name} says Woof!" | ||
|
||
|
||
class Greyhound(Dog): | ||
pet_type: str = UserProperty(SchemaConst("greyhound")) | ||
|
||
def speak(self): | ||
return f"{self.name}, the greyhound, says Woof!" | ||
|
||
|
||
class Cat(Pet): | ||
pet_type: str = UserProperty(SchemaConst("cat")) | ||
|
||
def speak(self): | ||
return f"{self.name} says Miaow!" |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
VERSION = (0, 2, 2) | ||
VERSION = (0, 2, 3) | ||
|
||
__version__ = '.'.join(map(str, VERSION)) |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
from .ReadsJSON import ReadsJSON | ||
from .ReadsYAML import ReadsYAML | ||
from .RegistersSubclasses import RegistersSubclasses | ||
from .RegistersSubclasses import RegistersSubclasses, has_registered_subclasses |
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