Skip to content

Commit f6e2b74

Browse files
committed
Read in files as UTF-8
1 parent f3a7838 commit f6e2b74

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

shiny/_custom_component_template_questions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def update_names_in_files(dir: Path):
138138
for item in dir.iterdir():
139139
if item.is_file():
140140
# Only do this for files
141-
with open(item, "r") as f:
141+
with open(item, "r", encoding="utf-8") as f:
142142
file_contents = f.read()
143143
# First, "custom_component" -> "new_component_name"
144144
file_contents = file_contents.replace(
@@ -151,7 +151,7 @@ def update_names_in_files(dir: Path):
151151
old_capital_case_name, capital_case_name
152152
)
153153

154-
with open(item, "w") as f:
154+
with open(item, "w", encoding="utf-8") as f:
155155
f.write(file_contents)
156156

157157
# Loop over dirs_to_update and run the update function on them

shiny/_docstring.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class DocStringWithExample(str): ...
6161
class ExampleWriter:
6262
def write_example(self, app_files: list[str]) -> str:
6363
app_file = app_files[0]
64-
with open(app_file) as f:
64+
with open(app_file, encoding="utf-8") as f:
6565
code = f.read()
6666

6767
return f"```.python\n{code.strip()}\n```\n"
@@ -209,7 +209,7 @@ def is_express_app(app_path: str) -> bool:
209209
if not os.path.exists(app_path):
210210
return False
211211

212-
with open(app_path) as f:
212+
with open(app_path, encoding="utf-8") as f:
213213
for line in f:
214214
if "from shiny.express" in line:
215215
return True

shiny/quarto.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ def convert_code_cells_to_app_py(json_file: str | Path, app_file: str | Path) ->
3636
app_file = Path(app_file)
3737

3838
if app_file.exists():
39-
with open(app_file, "r") as f:
39+
with open(app_file, "r", encoding="utf-8") as f:
4040
first_line = f.readline().strip()
4141
if first_line != "# This file generated by Quarto; do not edit by hand.":
4242
raise ValueError(
4343
f"Not overwriting app file {app_file}, because it does not appear to be generated by Quarto. "
4444
" If this is incorrect, remove the file and try again."
4545
)
4646

47-
with open(json_file, "r") as f:
47+
with open(json_file, "r", encoding="utf-8") as f:
4848
data = cast(QuartoShinyCodeCells, json.load(f))
4949

5050
if data["schema_version"] != 1:
@@ -93,7 +93,7 @@ def server(input: Inputs, output: Outputs, session: Session) -> None:
9393
)
9494
"""
9595

96-
with open(app_file, "w") as f:
96+
with open(app_file, "w", encoding="utf-8") as f:
9797
f.write(app_content)
9898

9999

0 commit comments

Comments
 (0)