From a89cbde62e377f4d15668ad31fc487c9ebe364fe Mon Sep 17 00:00:00 2001 From: "John N. Milner" Date: Tue, 30 Apr 2024 11:28:08 -0400 Subject: [PATCH 1/2] Add r prefix to regex string Fixes "DeprecationWarning: invalid escape sequence '\s'" --- src/formpack/utils/expand_content.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/formpack/utils/expand_content.py b/src/formpack/utils/expand_content.py index 2b9774f..71030b7 100644 --- a/src/formpack/utils/expand_content.py +++ b/src/formpack/utils/expand_content.py @@ -303,7 +303,7 @@ def _mark_special(**kwargs: str) -> None: def _expand_type_to_dict(type_str: str) -> Dict[str, Union[str, bool]]: SELECT_PATTERN = r'^({select_type})\s+(\S+)$' out = {} - match = re.search('\s+(or.other)$', type_str) + match = re.search(r'\s+(or.other)$', type_str) if match: type_str = type_str.replace(match.groups()[0], '').strip() out[OR_OTHER_COLUMN] = True From 768ee674a4314a3390c944b8f7edcf57268f86ca Mon Sep 17 00:00:00 2001 From: "John N. Milner" Date: Tue, 30 Apr 2024 11:32:28 -0400 Subject: [PATCH 2/2] Switch export tests from `isfile()` to `is_file()` Resolves "DeprecationWarning: isfile is deprecated; use is_file" --- tests/test_exports.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/test_exports.py b/tests/test_exports.py index 42773a6..70f299a 100644 --- a/tests/test_exports.py +++ b/tests/test_exports.py @@ -444,7 +444,7 @@ def test_simple_nested_grouped_repeatable(self): with TempDir() as d: xls = d / 'foo.xlsx' export.to_xlsx(xls, submissions) - assert xls.isfile() + assert xls.is_file() def test_repeats(self): title, schemas, submissions = build_fixture('grouped_repeatable') @@ -1889,7 +1889,7 @@ def test_xlsx(self): with TempDir() as d: xls = d / 'foo.xlsx' fp.export(**options).to_xlsx(xls, submissions) - assert xls.isfile() + assert xls.is_file() def test_xlsx_with_types(self): title, schemas, submissions = build_fixture('nested_grouped_repeatable') @@ -1899,7 +1899,7 @@ def test_xlsx_with_types(self): with TempDir() as d: xls = d / 'foo.xlsx' fp.export(**options).to_xlsx(xls, submissions) - assert xls.isfile() + assert xls.is_file() def test_xlsx_long_sheet_names_and_invalid_chars(self): title, schemas, submissions = build_fixture('long_names') @@ -1912,7 +1912,7 @@ def test_xlsx_long_sheet_names_and_invalid_chars(self): with TempDir() as d: xls = d / 'foo.xlsx' fp.export(**options).to_xlsx(xls, submissions) - assert xls.isfile() + assert xls.is_file() book = openpyxl.load_workbook(xls) assert book.sheetnames == [ 'long survey name_ the quick,...', @@ -1943,7 +1943,7 @@ def test_xlsx_too_long_string(self): with TempDir() as d: xls = d / 'foo.xlsx' fp.export().to_xlsx(xls, submissions) - assert xls.isfile() + assert xls.is_file() book = openpyxl.load_workbook(xls) sheet = book[title] row_values = [cell.value for cell in sheet[2]] @@ -1974,7 +1974,7 @@ def test_xlsx_too_long_url(self): with TempDir() as d: xls = d / 'foo.xlsx' fp.export().to_xlsx(xls, submissions) - assert xls.isfile() + assert xls.is_file() book = openpyxl.load_workbook(xls) sheet = book[title] row_values = [cell.value for cell in sheet[2]] @@ -2018,7 +2018,7 @@ def test_xlsx_with_tag_headers(self): with TempDir() as d: xls = d / 'foo.xlsx' fp.export(**options).to_xlsx(xls, submissions) - assert xls.isfile() + assert xls.is_file() book = openpyxl.load_workbook(xls, data_only=True) # Verify main sheet sheet = book['Household survey with HXL an...'] @@ -2159,7 +2159,7 @@ def test_copy_fields_and_force_index_and_unicode(self): with TempDir() as d: xls = d / 'test.xlsx' fp.export().to_xlsx(xls, submissions) - assert xls.isfile() + assert xls.is_file() def test_copy_fields_multiple_versions(self): title, schemas, submissions = restaurant_profile