-
Notifications
You must be signed in to change notification settings - Fork 1
/
2_owners.py
48 lines (36 loc) · 1.33 KB
/
2_owners.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from datetime import date
from chalk import owner
from chalk.features import feature, features
@features
class User:
id: str
# Owners are specified via code comments:
# :owner: katherine.johnson@nasa.gov
name: str
@features
class User1:
id: str
# or explicitly with `feature(owner=...)`:
name: str = feature(owner="katherine.johnson@nasa.gov")
# Setting an owner through the `@features` decorator
# determines the owner all the features on the class
@features(owner="katherine.johnson@nasa.gov")
class User2:
id: str # assigned the owner katherine.johnson@nasa.gov
name: str # assigned the owner katherine.johnson@nasa.gov
# Owners on features are more specific than owners
# set via the `@features` decorator.
@features(owner="katherine.johnson@nasa.gov")
class User3:
# Katherine is the owner of the id and dob feature,
# because she is the owner set in the `@features` decorator
id: str
dob: date
# Annie is the owner of this feature because she is set
# as the owner at the feature level, which is more specific
# than the owner from the feature class
# :owner: annie.easley@nasa.gov
name: str
# The function `chalk.features.owner(...)` returns the owner of a feature
assert owner(User3.name) == "annie.easley@nasa.gov"
assert owner(User3.id) == "katherine.johnson@nasa.gov"