Skip to content

Commit

Permalink
Update save.py to use utf-8 instead of None per default (#3278)
Browse files Browse the repository at this point in the history
* Update save.py to use utf-8 instead of None per default

I experience issues with the Null on windows. It appears as if when saving HTML, the template is already utf-8 and when writing the files with the system default code page, there are encoding issues.

* incorporated tips from jonmmease 

- completely unchecked... trusting CI...

* - formated...

* - to trigger workflow..

* - to trigger workflow..

* Update altair/utils/save.py

Co-authored-by: Jon Mease <[email protected]>

* Update altair/utils/save.py

Co-authored-by: Jon Mease <[email protected]>

* fixed arg names..

* improved formating...

* more formating...

* more formating

* Update api.py

- fixed formating... wired...

---------

Co-authored-by: franz haas <[email protected]>
Co-authored-by: Jon Mease <[email protected]>
  • Loading branch information
3 people authored Dec 6, 2023
1 parent e1bb266 commit 6d1ded7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions altair/utils/save.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ def perform_save():

if format == "json":
json_spec = json.dumps(spec, **json_kwds)
write_file_or_filename(fp, json_spec, mode="w")
write_file_or_filename(
fp, json_spec, mode="w", encoding=kwargs.get("encoding", "utf-8")
)
elif format == "html":
if inline:
kwargs["template"] = "inline"
Expand All @@ -157,7 +159,12 @@ def perform_save():
json_kwds=json_kwds,
**kwargs,
)
write_file_or_filename(fp, mimebundle["text/html"], mode="w")
write_file_or_filename(
fp,
mimebundle["text/html"],
mode="w",
encoding=kwargs.get("encoding", "utf-8"),
)
elif format in ["png", "svg", "pdf", "vega"]:
mimebundle = spec_to_mimebundle(
spec=spec,
Expand Down
2 changes: 1 addition & 1 deletion altair/vegalite/v5/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3247,7 +3247,7 @@ def add_selection(self, *selections) -> Self:


def repeat(
repeater: Literal["row", "column", "repeat", "layer"] = "repeat"
repeater: Literal["row", "column", "repeat", "layer"] = "repeat",
) -> core.RepeatRef:
"""Tie a channel to the row or column within a repeated chart
Expand Down

0 comments on commit 6d1ded7

Please sign in to comment.