Skip to content

Commit 25f228d

Browse files
committed
json dumps wont force ascii characters
1 parent 642e600 commit 25f228d

5 files changed

Lines changed: 6 additions & 6 deletions

File tree

codemeta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
{
6363
"@type": "Person",
6464
"givenName": "Jens",
65-
"familyName": "Br\u00f6der",
65+
"familyName": "Bröder",
6666
"email": "j.broeder@fz-juelich.de",
6767
"@id": "https://orcid.org/0000-0001-7939-226X"
6868
},

src/somesy/codemeta/writer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def _init_new_file(self) -> None:
8787
}
8888
# dump to file
8989
with self.path.open("w+") as f:
90-
json.dump(data, f, indent=2)
90+
json.dump(data, f, indent=2, ensure_ascii=False)
9191

9292
def save(self, path: Optional[Path] = None) -> None:
9393
"""Save the codemeta.json file."""
@@ -107,7 +107,7 @@ def save(self, path: Optional[Path] = None) -> None:
107107

108108
with path.open("w") as f:
109109
# codemeta.json indentation is 2 spaces
110-
json.dump(data, f, indent=2)
110+
json.dump(data, f, indent=2, ensure_ascii=False)
111111

112112
@staticmethod
113113
def _from_person(person: Person):

src/somesy/core/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def model_dump_json(self, *args, **kwargs):
115115

116116
if by_alias:
117117
ret = {self.model_fields[k].alias or k: v for k, v in ret.items()}
118-
return json.dumps(ret)
118+
return json.dumps(ret, ensure_ascii=False)
119119

120120

121121
_SOMESY_TARGETS = ["cff", "pyproject", "package_json", "codemeta"]

src/somesy/package_json/writer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def save(self, path: Optional[Path] = None) -> None:
7272

7373
with path.open("w") as f:
7474
# package.json indentation is 2 spaces
75-
json.dump(self._data, f, indent=2)
75+
json.dump(self._data, f, indent=2, ensure_ascii=False)
7676

7777
@staticmethod
7878
def _from_person(person: Person):

tests/output/test_codemeta.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def test_update_codemeta(somesy_input, tmp_path):
3535
with open(codemeta_file, "w") as f:
3636
codemeta = json.loads(dat3)
3737
codemeta["version"] = "0.0.2"
38-
json.dump(codemeta, f)
38+
json.dump(codemeta, f, ensure_ascii=False)
3939
cm.sync(somesy_input.project)
4040
cm.save()
4141
assert codemeta_file.is_file()

0 commit comments

Comments
 (0)