-
-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Fix #445 casting on dottet get. Fix the rebound of `cast` on dotted get. Fix #445 * better handling of casting data
- Loading branch information
1 parent
9a5fcd7
commit 2071842
Showing
6 changed files
with
76 additions
and
3 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 @@ | ||
export DYNACONF_UPSTREAM_ROOK__BUILD_ROOK_FROM_GIT=TRUE |
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,48 @@ | ||
# [bug] Casting does not work with Box'd settings (eg dicts) | ||
|
||
* created by @jhesketh on 2020-10-08 12:01:21 +0000 UTC | ||
|
||
**Describe the bug** | ||
Using any of the cast or "as_bool" etc methods do not work with nested/boxed settings. | ||
|
||
**To Reproduce** | ||
|
||
<details> | ||
<summary> Python interpreter </summary> | ||
|
||
```python | ||
|
||
>>> settings.UPSTREAM_ROOK | ||
<Box: {'BUILD_ROOK_FROM_GIT': 'TRUE'}> | ||
>>> settings.UPSTREAM_ROOK.BUILD_ROOK_FROM_GIT | ||
'TRUE' | ||
>>> settings.as_bool('UPSTREAM_ROOK.BUILD_ROOK_FROM_GIT') | ||
False | ||
>>> settings.get('UPSTREAM_ROOK.BUILD_ROOK_FROM_GIT') | ||
'TRUE' | ||
>>> settings.get('UPSTREAM_ROOK.BUILD_ROOK_FROM_GIT', cast="@bool") | ||
False | ||
|
||
``` | ||
</details> | ||
|
||
2. Having the following config files: | ||
|
||
<!-- Please adjust if you are using different files and formats! --> | ||
|
||
<details> | ||
<summary> Config files </summary> | ||
|
||
``` | ||
[upstream_rook] | ||
build_rook_from_git = true | ||
``` | ||
|
||
|
||
</details> | ||
|
||
|
||
**Expected behavior** | ||
|
||
`settings.as_bool('UPSTREAM_ROOK.BUILD_ROOK_FROM_GIT')` returns `True`. | ||
|
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,11 @@ | ||
from dynaconf import Dynaconf | ||
|
||
settings = Dynaconf(load_dotenv=True) | ||
|
||
assert settings.get("UPSTREAM_ROOK.BUILD_ROOK_FROM_GIT") == "TRUE" | ||
|
||
assert ( | ||
settings.as_bool("UPSTREAM_ROOK.BUILD_ROOK_FROM_GIT") is True | ||
), settings.as_bool("UPSTREAM_ROOK.BUILD_ROOK_FROM_GIT") | ||
|
||
assert settings.get("UPSTREAM_ROOK__BUILD_ROOK_FROM_GIT", cast="@bool") is True |