Skip to content

Commit 5fdb441

Browse files
authored
Rename subcast param of env.dict to subcast_values (#182)
1 parent 80de46a commit 5fdb441

4 files changed

Lines changed: 6 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## 9.0.0 (unreleased)
44

5+
- _Backwards-incompatible_: Rename `subcast` param of `env.dict` to `subcast_values` for consistency with `subcast_keys`.
56
- _Backwards-incompatible_: Remove variable proxying. Use variable expansion instead (see 8.1.0 release notes below)
67
([#175](https://github.com/sloria/environs/issues/175)).
78
- _Backwards-incompatible_: Drop support for marshmallow 2 and Python 3.5,

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ The following are all type-casting methods of `Env`:
9494
- `env.float`
9595
- `env.decimal`
9696
- `env.list` (accepts optional `subcast` keyword argument)
97-
- `env.dict` (accepts optional `subcast` keyword argument)
97+
- `env.dict` (accepts optional `subcast_keys` and `subcast_values` keyword arguments)
9898
- `env.json`
9999
- `env.datetime`
100100
- `env.date`

environs/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,17 +156,17 @@ def _preprocess_list(value: typing.Union[str, typing.Iterable], **kwargs) -> typ
156156

157157
def _preprocess_dict(
158158
value: typing.Union[str, typing.Mapping],
159-
# TODO: Rename subcast to subcast_values and re-order arguments for next major release
160-
subcast: Subcast,
159+
*,
161160
subcast_key: typing.Optional[Subcast] = None,
161+
subcast_values: typing.Optional[Subcast] = None,
162162
**kwargs,
163163
) -> typing.Mapping:
164164
if isinstance(value, Mapping):
165165
return value
166166

167167
return {
168168
(subcast_key(key.strip()) if subcast_key else key.strip()): (
169-
subcast(val.strip()) if subcast else val.strip()
169+
subcast_values(val.strip()) if subcast_values else val.strip()
170170
)
171171
for key, val in (item.split("=", 1) for item in value.split(",") if value)
172172
}

tests/test_environs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def test_dict(self, set_env, env):
107107

108108
def test_dict_with_subcast(self, set_env, env):
109109
set_env({"DICT": "key1=1,key2=2"})
110-
assert env.dict("DICT", subcast=int) == {"key1": 1, "key2": 2}
110+
assert env.dict("DICT", subcast_values=int) == {"key1": 1, "key2": 2}
111111

112112
def test_dict_without_subcast_key(self, set_env, env):
113113
set_env({"DICT": "1=value1,2=value2"})

0 commit comments

Comments
 (0)