Skip to content

Commit d3f3022

Browse files
committed
Fix JSON serialization
Extended the default_encoder function to handle Path objects by converting them to their string representation. This ensures that Path objects can be properly serialized to JSON format.
1 parent 84c885a commit d3f3022

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

bumpversion/show.py

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import dataclasses
44
from io import StringIO
5+
from pathlib import Path
56
from pprint import pprint
67
from typing import Any, Optional
78

@@ -39,6 +40,8 @@ def default_encoder(obj: Any) -> str:
3940
return str(obj)
4041
elif isinstance(obj, type):
4142
return obj.__name__
43+
elif isinstance(obj, Path):
44+
return str(obj)
4245
raise TypeError(f"Object of type {type(obj), str(obj)} is not JSON serializable")
4346

4447
print_info(json.dumps(value, sort_keys=True, indent=2, default=default_encoder))

0 commit comments

Comments
 (0)