Skip to content

Commit cc80dfa

Browse files
Merge pull request #123 from phenobarbital/new-mutables
fixing support for dynamic fields
2 parents 0057f99 + 3b09fc2 commit cc80dfa

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

datamodel/abstract.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,6 @@ def __new__(cls, name, bases, attrs, **kwargs):
117117
df.type = _type
118118
cols[field] = df
119119
attrs[field] = df
120-
elif strict is True and field not in attrs:
121-
raise ValueError(
122-
f"Cannot create a new Field {field} on {cls.__name__}"
123-
)
124120
else:
125121
# add a new field, based on type
126122
df = Field(type=_type, required=False, default=None)

datamodel/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
__title__ = 'python-datamodel'
44
__description__ = ('simple library based on python +3.8 to use Dataclass-syntax'
55
'for interacting with Data')
6-
__version__ = '0.3.5'
6+
__version__ = '0.3.6'
77
__author__ = 'Jesus Lara'
88
__author_email__ = '[email protected]'
99
__license__ = 'BSD'

examples/dynamic.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33
from datamodel import BaseModel, Column
44

55

6+
class AuthBackend(BaseModel):
7+
name: str
8+
uri: str
9+
description: str
10+
icon: str
11+
external: bool = Column(required=True, default=False)
12+
headers: dict = Column(required=False, default_factory=dict)
13+
14+
class Meta:
15+
strict = True
16+
frozen = False
17+
618
class Identity(BaseModel):
719
"""Identity.
820

0 commit comments

Comments
 (0)