From 24d1a11abdedfa2d03e08206c7acf49480d5e56e Mon Sep 17 00:00:00 2001 From: Ashley Heath Date: Wed, 13 Dec 2023 09:50:59 +0000 Subject: [PATCH 1/2] Set encoding=utf-8 when reading files --- procrastinate/contrib/django/migrations_magic.py | 2 +- procrastinate/schema.py | 2 +- procrastinate/sql/__init__.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/procrastinate/contrib/django/migrations_magic.py b/procrastinate/contrib/django/migrations_magic.py index b0d22b30a..65bf12e64 100644 --- a/procrastinate/contrib/django/migrations_magic.py +++ b/procrastinate/contrib/django/migrations_magic.py @@ -72,7 +72,7 @@ def list_migration_files() -> Iterable[Tuple[str, str]]: Returns a list of filenames and file contents for all migration files """ return [ - (p.name, p.read_text()) + (p.name, p.read_text(encoding="utf-8")) for p in importlib_resources.files("procrastinate.sql.migrations").iterdir() if p.name.endswith(".sql") ] diff --git a/procrastinate/schema.py b/procrastinate/schema.py index 5e2c94eda..f8200548f 100644 --- a/procrastinate/schema.py +++ b/procrastinate/schema.py @@ -20,7 +20,7 @@ def __init__(self, connector: connector_module.BaseConnector): def get_schema() -> str: return ( importlib_resources.files("procrastinate.sql") / "schema.sql" - ).read_text() + ).read_text(encoding="utf-8") @staticmethod def get_migrations_path() -> str: diff --git a/procrastinate/sql/__init__.py b/procrastinate/sql/__init__.py index 5d5d88833..4c82a1360 100644 --- a/procrastinate/sql/__init__.py +++ b/procrastinate/sql/__init__.py @@ -27,7 +27,7 @@ def parse_query_file(query_file: str) -> Dict["str", "str"]: def get_queries() -> Dict["str", "str"]: return parse_query_file( - (importlib_resources.files("procrastinate.sql") / "queries.sql").read_text() + (importlib_resources.files("procrastinate.sql") / "queries.sql").read_text(encoding="utf-8") ) From 08bf5a4ec9452260566e017e39ff2f12ac33a81f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 13 Dec 2023 09:56:04 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- procrastinate/sql/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/procrastinate/sql/__init__.py b/procrastinate/sql/__init__.py index 4c82a1360..73c002540 100644 --- a/procrastinate/sql/__init__.py +++ b/procrastinate/sql/__init__.py @@ -27,7 +27,9 @@ def parse_query_file(query_file: str) -> Dict["str", "str"]: def get_queries() -> Dict["str", "str"]: return parse_query_file( - (importlib_resources.files("procrastinate.sql") / "queries.sql").read_text(encoding="utf-8") + (importlib_resources.files("procrastinate.sql") / "queries.sql").read_text( + encoding="utf-8" + ) )