diff --git a/scripts/extract_markdown.py b/scripts/extract_markdown.py index 10646a51..7bcd08ca 100755 --- a/scripts/extract_markdown.py +++ b/scripts/extract_markdown.py @@ -150,7 +150,7 @@ def main(): try: if args.input_file: - with open(args.input_file, "r") as f: + with open(args.input_file, "r", encoding="utf8") as f: content = f.read() elif args.input: content = args.input @@ -164,7 +164,7 @@ def main(): ) if args.output_file: # Write to file - with open(args.output_file, "w") as f: + with open(args.output_file, "w", encoding="utf8") as f: f.write(extracted_content) else: # Write to std output diff --git a/scripts/generate_config_md.py b/scripts/generate_config_md.py index 7ec69a0f..ae7120c4 100755 --- a/scripts/generate_config_md.py +++ b/scripts/generate_config_md.py @@ -150,7 +150,7 @@ def main(): config_md = generate_config_md() if args.output_file: # Write to file - with open(args.output_file, "w") as f: + with open(args.output_file, "w", encoding="utf8") as f: f.write(config_md) else: # Write to std output diff --git a/scripts/generate_openapi.py b/scripts/generate_openapi.py index 8c9e108e..72eaca4e 100755 --- a/scripts/generate_openapi.py +++ b/scripts/generate_openapi.py @@ -54,7 +54,7 @@ def main(): openapi_spec_str = json.dumps(openapi_spec, indent=2) if args.output_file: # Write to file - with open(args.output_file, "w") as f: + with open(args.output_file, "w", encoding="utf8") as f: f.write(openapi_spec_str) else: # Write to std output diff --git a/scripts/generate_openapi_md.py b/scripts/generate_openapi_md.py index fae29195..a2747591 100755 --- a/scripts/generate_openapi_md.py +++ b/scripts/generate_openapi_md.py @@ -286,7 +286,7 @@ def main(): openapi_md = generate_openapi_md() if args.output_file: # Write to file - with open(args.output_file, "w") as f: + with open(args.output_file, "w", encoding="utf8") as f: f.write(openapi_md) else: # Write to std output diff --git a/tests/test_doc.py b/tests/test_doc.py index 7fc71733..7d4f6b9a 100644 --- a/tests/test_doc.py +++ b/tests/test_doc.py @@ -47,7 +47,7 @@ def test_openapi_md_current(config_eos): expected_spec_md_path = DIR_PROJECT_ROOT / "docs" / "_generated" / "openapi.md" new_spec_md_path = DIR_TESTDATA / "openapi-new.md" - with open(expected_spec_md_path) as f_expected: + with open(expected_spec_md_path, encoding="utf8") as f_expected: expected_spec_md = f_expected.read() # Patch get_config and import within guard to patch global variables within the fastapi_server module. @@ -59,7 +59,7 @@ def test_openapi_md_current(config_eos): spec_md = generate_openapi_md.generate_openapi_md() - with open(new_spec_md_path, "w") as f_new: + with open(new_spec_md_path, "w", encoding="utf8") as f_new: f_new.write(spec_md) try: @@ -76,7 +76,7 @@ def test_config_md_current(config_eos): expected_config_md_path = DIR_PROJECT_ROOT / "docs" / "_generated" / "config.md" new_config_md_path = DIR_TESTDATA / "config-new.md" - with open(expected_config_md_path) as f_expected: + with open(expected_config_md_path, encoding="utf8") as f_expected: expected_config_md = f_expected.read() # Patch get_config and import within guard to patch global variables within the fastapi_server module. @@ -88,7 +88,7 @@ def test_config_md_current(config_eos): config_md = generate_config_md.generate_config_md() - with open(new_config_md_path, "w") as f_new: + with open(new_config_md_path, "w", encoding="utf8") as f_new: f_new.write(config_md) try: diff --git a/tests/test_pvforecastakkudoktor.py b/tests/test_pvforecastakkudoktor.py index 39b3f16f..453e44c3 100644 --- a/tests/test_pvforecastakkudoktor.py +++ b/tests/test_pvforecastakkudoktor.py @@ -61,7 +61,7 @@ def sample_settings(config_eos): @pytest.fixture def sample_forecast_data(): """Fixture that returns sample forecast data converted to pydantic model.""" - with open(FILE_TESTDATA_PV_FORECAST_INPUT_1, "r") as f_in: + with open(FILE_TESTDATA_PV_FORECAST_INPUT_1, "r", encoding="utf8") as f_in: input_data = f_in.read() return PVForecastAkkudoktor._validate_data(input_data) @@ -69,7 +69,7 @@ def sample_forecast_data(): @pytest.fixture def sample_forecast_data_raw(): """Fixture that returns raw sample forecast data.""" - with open(FILE_TESTDATA_PV_FORECAST_INPUT_1, "r") as f_in: + with open(FILE_TESTDATA_PV_FORECAST_INPUT_1, "r", encoding="utf8") as f_in: input_data = f_in.read() return input_data @@ -77,7 +77,7 @@ def sample_forecast_data_raw(): @pytest.fixture def sample_forecast_report(): """Fixture that returns sample forecast data report.""" - with open(FILE_TESTDATA_PV_FORECAST_RESULT_1, "r") as f_res: + with open(FILE_TESTDATA_PV_FORECAST_RESULT_1, "r", encoding="utf8") as f_res: input_data = f_res.read() return input_data diff --git a/tests/test_weatherclearoutside.py b/tests/test_weatherclearoutside.py index 54aec878..0a0aacec 100644 --- a/tests/test_weatherclearoutside.py +++ b/tests/test_weatherclearoutside.py @@ -43,7 +43,7 @@ def sample_clearout_1_html(): @pytest.fixture def sample_clearout_1_data(): """Fixture that returns sample forecast data.""" - with open(FILE_TESTDATA_WEATHERCLEAROUTSIDE_1_DATA, "r") as f_in: + with open(FILE_TESTDATA_WEATHERCLEAROUTSIDE_1_DATA, "r", encoding="utf8") as f_in: json_str = f_in.read() data = WeatherClearOutside.from_json(json_str) return data @@ -212,7 +212,7 @@ def test_development_forecast_data(mock_get, weather_provider, sample_clearout_1 # Fill the instance weather_provider.update_data(force_enable=True) - with open(FILE_TESTDATA_WEATHERCLEAROUTSIDE_1_DATA, "w") as f_out: + with open(FILE_TESTDATA_WEATHERCLEAROUTSIDE_1_DATA, "w", encoding="utf8") as f_out: f_out.write(weather_provider.to_json())