From 94a19dd757b9b7897465c980020ea95ccb8e9bb7 Mon Sep 17 00:00:00 2001 From: Alex Hedges Date: Tue, 15 Jul 2025 15:29:51 -0400 Subject: [PATCH 1/3] Fix `SyntaxError: invalid escape sequence` exceptions These were caused by not using raw strings in the grammar. I discovered this problem when running tests on a repository that uses `daidepp` with a more strict configuration. --- src/daidepp/grammar/grammar.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/daidepp/grammar/grammar.py b/src/daidepp/grammar/grammar.py index dd8db31..7601701 100644 --- a/src/daidepp/grammar/grammar.py +++ b/src/daidepp/grammar/grammar.py @@ -43,11 +43,11 @@ "prov_landlock": '"BOH" / "BUD" / "BUR" / "MOS" / "MUN" / "GAL" / "PAR" / "RUH" / "SER" / "SIL" / "TYR" / "UKR" / "VIE" / "WAR" ', "prov_sea": '"ADR" / "AEG" / "BAL" / "BAR" / "BLA" / "GOB" / "EAS" / "ECH" / "HEL" / "ION" / "IRI" / "GOL" / "MAO" / "NAO" / "NTH" / "NWG" / "SKA" / "TYS" / "WES"', "supply_center": '"ANK" / "BEL" / "BER" / "BRE" / "BUD" / "BUL" / "CON" / "DEN" / "EDI" / "GRE" / "HOL" / "KIE" / "LON" / "LVP" / "MAR" / "MOS" / "MUN" / "NAP" / "NWY" / "PAR" / "POR" / "ROM" / "RUM" / "SER" / "SEV" / "SMY" / "SPA" / "STP" / "SWE" / "TRI" / "TUN" / "VEN" / "VIE" / "WAR"', - "turn": 'season ws ~"\d{4}"', + "turn": r'season ws ~r"\d{4}"', "season": '"SPR" / "SUM" / "FAL" / "AUT" / "WIN"', - "lpar": '~"\s*\(\s*"', - "rpar": '~"\s*\)\s*"', - "ws": '~"\s+"', + "lpar": r'~r"\s*\(\s*"', + "rpar": r'~r"\s*\)\s*"', + "ws": r'~r"\s+"', } # Peace and Alliances @@ -102,7 +102,7 @@ # Nested Multipart Arrangements LEVEL_50: GrammarDict = { - "cho": '"CHO" lpar (~"\d+ \d+") rpar (lpar arrangement rpar)+', + "cho": r'"CHO" lpar (~r"\d+ \d+") rpar (lpar arrangement rpar)+', "sub_arrangement": f"{TRAIL_TOKEN}and / orr / cho", "arrangement": f"{TRAIL_TOKEN}cho", "try_tokens": f'{TRAIL_TOKEN}"CHO"', # This isn't included in the original daide spec but I think they just forgot it. @@ -204,7 +204,7 @@ # Utilities LEVEL_160: GrammarDict = { - "float": 'ws*~"[-+]?((\d*\.\d+)|(\d+\.?))([Ee][+-]?\d+)?"', + "float": r'ws*~r"[-+]?((\d*\.\d+)|(\d+\.?))([Ee][+-]?\d+)?"', "ulb": '"ULB" lpar power float rpar', "uub": '"UUB" lpar power float rpar', "sub_arrangement": f"{TRAIL_TOKEN}ulb / uub", From 483f95eb3cc464ee5e789e9ba5b995c8ebc7f3bd Mon Sep 17 00:00:00 2001 From: Alex Hedges Date: Tue, 15 Jul 2025 16:04:41 -0400 Subject: [PATCH 2/3] Error on all warnings during tests The previous commit fixes the `DeprecationWarning`s that were being suppressed, so this is now safe to enable. --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 47cd469..47713cf 100644 --- a/setup.cfg +++ b/setup.cfg @@ -59,7 +59,7 @@ addopts = --cov-report html timeout = 10 filterwarnings = - ignore::DeprecationWarning + error [pylint.MESSAGES CONTROL] extension-pkg-whitelist = From c725e6a35a900dcb975ef01a60517d361e988af0 Mon Sep 17 00:00:00 2001 From: Alex Hedges Date: Fri, 18 Jul 2025 16:00:40 -0400 Subject: [PATCH 3/3] Run `pytest` under stricter conditions This enables more errors and warnings, which should prevent regressing on problems that have already been fixed. I tried to also add `-X warn_default_encoding`, but `regex` (required by `parsimonious`) fails with it enabled. --- .github/workflows/test-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-pr.yml b/.github/workflows/test-pr.yml index 606ad85..f7e9d1f 100644 --- a/.github/workflows/test-pr.yml +++ b/.github/workflows/test-pr.yml @@ -43,4 +43,4 @@ jobs: pip install -e .[dev] - name: Test run: | - pytest + python -X dev -bb -m pytest