-
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.
Defer evaluation of a UserObject schema entirely to resolve #55
- Loading branch information
Showing
6 changed files
with
125 additions
and
52 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
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