From a3a183b86c8b4f003e490b11e78e34fd2ea6e6d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dni=20=E2=9A=A1?= Date: Thu, 28 Jul 2022 12:15:27 +0200 Subject: [PATCH] fix test warnings when using < python3.8 (#798) * jinja warning * fix regex Co-authored-by: dni --- lnbits/bolt11.py | 4 ++-- lnbits/jinja2_templating.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lnbits/bolt11.py b/lnbits/bolt11.py index cc841585..67039740 100644 --- a/lnbits/bolt11.py +++ b/lnbits/bolt11.py @@ -61,7 +61,7 @@ def decode(pr: str) -> Invoice: invoice = Invoice() # decode the amount from the hrp - m = re.search("[^\d]+", hrp[2:]) + m = re.search(r"[^\d]+", hrp[2:]) if m: amountstr = hrp[2 + m.end() :] if amountstr != "": @@ -296,7 +296,7 @@ def _unshorten_amount(amount: str) -> int: # BOLT #11: # A reader SHOULD fail if `amount` contains a non-digit, or is followed by # anything except a `multiplier` in the table above. - if not re.fullmatch("\d+[pnum]?", str(amount)): + if not re.fullmatch(r"\d+[pnum]?", str(amount)): raise ValueError("Invalid amount '{}'".format(amount)) if unit in units: diff --git a/lnbits/jinja2_templating.py b/lnbits/jinja2_templating.py index 5abcd0bf..385703d1 100644 --- a/lnbits/jinja2_templating.py +++ b/lnbits/jinja2_templating.py @@ -21,7 +21,7 @@ class Jinja2Templates(templating.Jinja2Templates): self.env = self.get_environment(loader) def get_environment(self, loader: "jinja2.BaseLoader") -> "jinja2.Environment": - @jinja2.contextfunction + @jinja2.pass_context def url_for(context: dict, name: str, **path_params: typing.Any) -> str: request: Request = context["request"] return request.app.url_path_for(name, **path_params)