We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e13b0f0 commit 62dfe8eCopy full SHA for 62dfe8e
bumpversion/autocast.py
@@ -43,11 +43,14 @@ def listify(s: str) -> list:
43
Returns:
44
List of homogenous basic types.
45
"""
46
- if "," not in s and "\n" not in s:
+ if "\n" in s:
47
+ str_list = s.strip().split("\n")
48
+ elif "," in s:
49
+ str_list = s.strip().split(",")
50
+ else:
51
raise ValueError("Not a List")
52
53
# derive the type of the variable
- str_list = s.strip().split(",") if "," in s else s.strip().split("\n")
54
element_caster = str
55
for caster in (boolify, int, float, noneify, element_caster):
56
with contextlib.suppress(ValueError):
tests/fixtures/legacy_multiline_search_comma.cfg
@@ -0,0 +1,8 @@
1
+[bumpversion]
2
+current_version = 1.0.0
3
+
4
+[bumpversion:file:MULTILINE_SEARCH.md]
5
+search = **unreleased**,
6
+ **v{current_version}**,
7
+replace = **unreleased**,
8
+ **v{new_version}**,
tests/fixtures/legacy_multiline_search_comma_expected.json
@@ -0,0 +1,11 @@
+{
+ "current_version": "1.0.0",
+ "files": [
+ {
+ "filename": "MULTILINE_SEARCH.md",
+ "search": "**unreleased**,\n**v{current_version}**,",
+ "replace": "**unreleased**,\n**v{new_version}**,"
+ }
9
+ ],
10
+ "parts": {}
11
+}
tests/test_autocast.py
@@ -46,6 +46,7 @@ def test_noneify():
param("1,2,3,4", [1, 2, 3, 4], id="int"),
param("1\n2\n3\n4", [1, 2, 3, 4], id="int"),
param("s,t,r", ["s", "t", "r"], id="str"),
+ param("s,\nt,\nr\n", ["s,", "t,", "r"], id="str_newline"),
param("1.1,2,3.14", [1.1, 2.0, 3.14], id="float"),
param("True,False,true,false", [True, False, True, False], id="bool"),
param("None,None,None", [None, None, None], id="none"),
@@ -75,6 +76,7 @@ def test_listify_invalid():
75
76
param("False", False, id="False"),
77
param("1,2,3,4", [1, 2, 3, 4], id="int-list"),
78
param("s,t,r", ["s", "t", "r"], id="str-list"),
79
+ param("s,\nt,\nr\n", ["s,", "t,", "r"], id="str-list-newline"),
80
param("1", 1, id="int"),
81
param("1.0", 1.0, id="float"),
82
param(1, 1, id="real-int"),
tests/test_config/test_files_legacy.py
@@ -35,6 +35,11 @@ def cfg_file(request) -> str:
35
[
36
param("basic_cfg.cfg", "basic_cfg_expected.json", id="ini basic cfg"),
37
param("legacy_multiline_search.cfg", "legacy_multiline_search_expected.json", id="multiline search cfg"),
38
+ param(
39
+ "legacy_multiline_search_comma.cfg",
40
+ "legacy_multiline_search_comma_expected.json",
41
+ id="multiline search comma cfg",
42
+ ),
],
)
def test_read_ini_file(conf_file: str, expected_file: str, fixtures_path: Path) -> None:
0 commit comments