-
Notifications
You must be signed in to change notification settings - Fork 4
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 #236 from phenobarbital/bugfix-optional-list-str
fix an segfault for infinite iteration on parse_type
- Loading branch information
Showing
4 changed files
with
51 additions
and
12 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
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,19 @@ | ||
from typing import Optional | ||
from datamodel import BaseModel, Field | ||
from datamodel.converters import parse_type | ||
|
||
class TestOptional(BaseModel): | ||
services_especialities: Optional[list] = Field(required=False) | ||
|
||
opt = TestOptional(services_especialities=None) | ||
columns = opt.get_columns() | ||
print('Columns ', columns) | ||
col = columns['services_especialities'] | ||
|
||
print(col, opt, columns) | ||
data = ['Pilates', 'Yoga', 'Mindfulness', 'Running', 'Pilates'] | ||
newval = parse_type(col, col.type, data) | ||
opt.set('services_especialities', newval) | ||
|
||
assert opt.services_especialities == data | ||
assert type(opt.services_especialities) == list |