-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
32 additions
and
14 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 |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
from datetime import datetime, date, time, timedelta | ||
from typing import ( | ||
List, Optional, Union, Tuple, Dict, NamedTuple, Type, DefaultDict, | ||
Set, FrozenSet, Generic, Annotated, Literal, Sequence, MutableSequence | ||
Set, FrozenSet, Generic, Annotated, Literal, Sequence, MutableSequence, Collection | ||
) | ||
|
||
import pytest | ||
|
@@ -2480,8 +2480,8 @@ class _(JSONWizard.Meta): | |
|
||
def test_sequence_and_mutable_sequence_are_supported(): | ||
""" | ||
Confirm `Sequence` and `MutableSequence` -- imported from | ||
either `typing` or `collections.abc` -- are supported. | ||
Confirm `Collection`, `Sequence`, and `MutableSequence` -- imported | ||
from either `typing` or `collections.abc` -- are supported. | ||
""" | ||
@dataclass | ||
class IssueFields: | ||
|
@@ -2499,6 +2499,7 @@ class Options(JSONWizard): | |
fields_tup: tuple[IssueFields] = IssueFields('A'), | ||
fields_var_tup: tuple[IssueFields, ...] = IssueFields('A'), | ||
list_of_int: MutableSequence[int] = field(default_factory=list) | ||
list_of_bool: Collection[bool] = field(default_factory=list) | ||
|
||
# initialize with defaults | ||
opt = Options.from_dict({ | ||
|
@@ -2549,3 +2550,11 @@ class Options(JSONWizard): | |
'ListOfInt': (1, '2', 3.0) | ||
}) | ||
assert opt.list_of_int == [1, 2, 3] | ||
|
||
# check annotated `Collection` maps to `list` | ||
opt = Options.from_dict({ | ||
'email': '[email protected]', | ||
'token': '<PASSWORD>', | ||
'ListOfBool': (1, '0', '1') | ||
}) | ||
assert opt.list_of_bool == [True, False, True] |