From 403ff875b1071c4dcbd935c6d707ca9c073da0c0 Mon Sep 17 00:00:00 2001 From: franzhaas Date: Sat, 2 Dec 2023 09:30:07 +0100 Subject: [PATCH 01/12] 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. --- altair/utils/save.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/altair/utils/save.py b/altair/utils/save.py index af2c7a981..01a341774 100644 --- a/altair/utils/save.py +++ b/altair/utils/save.py @@ -12,7 +12,7 @@ def write_file_or_filename( fp: Union[str, pathlib.PurePath, IO], content: Union[str, bytes], mode: str = "w", - encoding: Optional[str] = None, + encoding: Optional[str] = "utf-8", ) -> None: """Write content to fp, whether fp is a string, a pathlib Path or a file-like object""" From 4c3ae49dde2e0d60e688f8ca530b194c8523c125 Mon Sep 17 00:00:00 2001 From: franzhaas Date: Sat, 2 Dec 2023 17:33:40 +0100 Subject: [PATCH 02/12] incorporated tips from jonmmease - completely unchecked... trusting CI... --- altair/utils/save.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/altair/utils/save.py b/altair/utils/save.py index 01a341774..2389c3965 100644 --- a/altair/utils/save.py +++ b/altair/utils/save.py @@ -12,7 +12,7 @@ def write_file_or_filename( fp: Union[str, pathlib.PurePath, IO], content: Union[str, bytes], mode: str = "w", - encoding: Optional[str] = "utf-8", + encoding: Optional[str] = None, ) -> None: """Write content to fp, whether fp is a string, a pathlib Path or a file-like object""" @@ -142,7 +142,7 @@ 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="utf-8") elif format == "html": if inline: kwargs["template"] = "inline" @@ -157,7 +157,7 @@ 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="utf-8") elif format in ["png", "svg", "pdf", "vega"]: mimebundle = spec_to_mimebundle( spec=spec, From c49366b479afc5730a36244cf7d4cd87478c3a1f Mon Sep 17 00:00:00 2001 From: franz haas Date: Sun, 3 Dec 2023 09:13:47 +0100 Subject: [PATCH 03/12] - formated... --- altair/utils/save.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/altair/utils/save.py b/altair/utils/save.py index 2389c3965..8c5e65d33 100644 --- a/altair/utils/save.py +++ b/altair/utils/save.py @@ -157,7 +157,9 @@ def perform_save(): json_kwds=json_kwds, **kwargs, ) - write_file_or_filename(fp, mimebundle["text/html"], mode="w", encoding="utf-8") + write_file_or_filename( + fp, mimebundle["text/html"], mode="w", encoding="utf-8" + ) elif format in ["png", "svg", "pdf", "vega"]: mimebundle = spec_to_mimebundle( spec=spec, From 55e3162da0dfe672ab6b0e0d295eccc72fe78c6a Mon Sep 17 00:00:00 2001 From: franz haas Date: Sun, 3 Dec 2023 09:19:40 +0100 Subject: [PATCH 04/12] - to trigger workflow.. --- altair/utils/save.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/altair/utils/save.py b/altair/utils/save.py index 8c5e65d33..dd4a27351 100644 --- a/altair/utils/save.py +++ b/altair/utils/save.py @@ -20,7 +20,7 @@ def write_file_or_filename( with open(file=fp, mode=mode, encoding=encoding) as f: f.write(content) else: - fp.write(content) + fp.write(content) def set_inspect_format_argument( From c806b75940f77cb85cb6469020b588ab58b1866e Mon Sep 17 00:00:00 2001 From: franz haas Date: Sun, 3 Dec 2023 09:19:53 +0100 Subject: [PATCH 05/12] - to trigger workflow.. --- altair/utils/save.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/altair/utils/save.py b/altair/utils/save.py index dd4a27351..8c5e65d33 100644 --- a/altair/utils/save.py +++ b/altair/utils/save.py @@ -20,7 +20,7 @@ def write_file_or_filename( with open(file=fp, mode=mode, encoding=encoding) as f: f.write(content) else: - fp.write(content) + fp.write(content) def set_inspect_format_argument( From b8756c31a841e7ec4291bad2095a79c6bb357e5d Mon Sep 17 00:00:00 2001 From: franzhaas Date: Mon, 4 Dec 2023 22:02:34 +0100 Subject: [PATCH 06/12] Update altair/utils/save.py Co-authored-by: Jon Mease --- altair/utils/save.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/altair/utils/save.py b/altair/utils/save.py index 8c5e65d33..3a3cb1157 100644 --- a/altair/utils/save.py +++ b/altair/utils/save.py @@ -158,7 +158,7 @@ def perform_save(): **kwargs, ) write_file_or_filename( - fp, mimebundle["text/html"], mode="w", encoding="utf-8" + fp, mimebundle["text/html"], mode="w", encoding=kwargs.get("encoding", "utf-8") ) elif format in ["png", "svg", "pdf", "vega"]: mimebundle = spec_to_mimebundle( From 42f223b3a37701dc67d6e0af81d16981c7f117d7 Mon Sep 17 00:00:00 2001 From: franzhaas Date: Mon, 4 Dec 2023 22:02:45 +0100 Subject: [PATCH 07/12] Update altair/utils/save.py Co-authored-by: Jon Mease --- altair/utils/save.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/altair/utils/save.py b/altair/utils/save.py index 3a3cb1157..a010dae0f 100644 --- a/altair/utils/save.py +++ b/altair/utils/save.py @@ -142,7 +142,7 @@ def perform_save(): if format == "json": json_spec = json.dumps(spec, **json_kwds) - write_file_or_filename(fp, json_spec, mode="w", encoding="utf-8") + write_file_or_filename(fp, json_spec, mode="w", kwargs.get("encoding", "utf-8")) elif format == "html": if inline: kwargs["template"] = "inline" From 0e1192a770b9e9151532e9d5e2552ba01bb4e5d8 Mon Sep 17 00:00:00 2001 From: franzhaas Date: Mon, 4 Dec 2023 22:09:05 +0100 Subject: [PATCH 08/12] fixed arg names.. --- altair/utils/save.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/altair/utils/save.py b/altair/utils/save.py index a010dae0f..c3b32113b 100644 --- a/altair/utils/save.py +++ b/altair/utils/save.py @@ -142,7 +142,7 @@ def perform_save(): if format == "json": json_spec = json.dumps(spec, **json_kwds) - write_file_or_filename(fp, json_spec, mode="w", kwargs.get("encoding", "utf-8")) + write_file_or_filename(fp, json_spec, mode="w", encoding=kwargs.get("encoding", "utf-8")) elif format == "html": if inline: kwargs["template"] = "inline" From 304ed59c4e25e9590d67438434836964d8f71511 Mon Sep 17 00:00:00 2001 From: franzhaas Date: Mon, 4 Dec 2023 22:12:41 +0100 Subject: [PATCH 09/12] improved formating... --- altair/utils/save.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/altair/utils/save.py b/altair/utils/save.py index c3b32113b..374791e89 100644 --- a/altair/utils/save.py +++ b/altair/utils/save.py @@ -142,7 +142,12 @@ def perform_save(): if format == "json": json_spec = json.dumps(spec, **json_kwds) - write_file_or_filename(fp, json_spec, mode="w", encoding=kwargs.get("encoding", "utf-8")) + write_file_or_filename( + fp, + json_spec, + mode="w", + encoding=kwargs.get("encoding", "utf-8") + ) elif format == "html": if inline: kwargs["template"] = "inline" From fff657b2cf8f41603bb66f7c5d6e726bf44d2c41 Mon Sep 17 00:00:00 2001 From: franzhaas Date: Mon, 4 Dec 2023 22:15:31 +0100 Subject: [PATCH 10/12] more formating... --- altair/utils/save.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/altair/utils/save.py b/altair/utils/save.py index 374791e89..de942ec31 100644 --- a/altair/utils/save.py +++ b/altair/utils/save.py @@ -143,10 +143,7 @@ def perform_save(): if format == "json": json_spec = json.dumps(spec, **json_kwds) write_file_or_filename( - fp, - json_spec, - mode="w", - encoding=kwargs.get("encoding", "utf-8") + fp, json_spec, mode="w", encoding=kwargs.get("encoding", "utf-8") ) elif format == "html": if inline: @@ -163,7 +160,10 @@ def perform_save(): **kwargs, ) write_file_or_filename( - fp, mimebundle["text/html"], mode="w", encoding=kwargs.get("encoding", "utf-8") + fp, + mimebundle["text/html"], + mode="w", + encoding=kwargs.get("encoding", "utf-8") ) elif format in ["png", "svg", "pdf", "vega"]: mimebundle = spec_to_mimebundle( From a88b88598a95c10e85ffbc0fe49010c14a457bb9 Mon Sep 17 00:00:00 2001 From: franzhaas Date: Mon, 4 Dec 2023 22:17:09 +0100 Subject: [PATCH 11/12] more formating --- altair/utils/save.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/altair/utils/save.py b/altair/utils/save.py index de942ec31..1784cc43e 100644 --- a/altair/utils/save.py +++ b/altair/utils/save.py @@ -163,7 +163,7 @@ def perform_save(): fp, mimebundle["text/html"], mode="w", - encoding=kwargs.get("encoding", "utf-8") + encoding=kwargs.get("encoding", "utf-8"), ) elif format in ["png", "svg", "pdf", "vega"]: mimebundle = spec_to_mimebundle( From 8124af135d01aa3753e932a51d04a2ddbfb084a6 Mon Sep 17 00:00:00 2001 From: franzhaas Date: Wed, 6 Dec 2023 15:59:05 +0100 Subject: [PATCH 12/12] Update api.py - fixed formating... wired... --- altair/vegalite/v5/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/altair/vegalite/v5/api.py b/altair/vegalite/v5/api.py index 730c2e107..c87c2e85d 100644 --- a/altair/vegalite/v5/api.py +++ b/altair/vegalite/v5/api.py @@ -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