fix test warnings when using < python3.8 (#798)

* jinja warning

* fix regex

Co-authored-by: dni <dni.khr@gmail.com>
This commit is contained in:
dni ⚡ 2022-07-28 12:15:27 +02:00 committed by GitHub
parent 04114c82f2
commit a3a183b86c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -61,7 +61,7 @@ def decode(pr: str) -> Invoice:
invoice = Invoice() invoice = Invoice()
# decode the amount from the hrp # decode the amount from the hrp
m = re.search("[^\d]+", hrp[2:]) m = re.search(r"[^\d]+", hrp[2:])
if m: if m:
amountstr = hrp[2 + m.end() :] amountstr = hrp[2 + m.end() :]
if amountstr != "": if amountstr != "":
@ -296,7 +296,7 @@ def _unshorten_amount(amount: str) -> int:
# BOLT #11: # BOLT #11:
# A reader SHOULD fail if `amount` contains a non-digit, or is followed by # A reader SHOULD fail if `amount` contains a non-digit, or is followed by
# anything except a `multiplier` in the table above. # 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)) raise ValueError("Invalid amount '{}'".format(amount))
if unit in units: if unit in units:

View File

@ -21,7 +21,7 @@ class Jinja2Templates(templating.Jinja2Templates):
self.env = self.get_environment(loader) self.env = self.get_environment(loader)
def get_environment(self, loader: "jinja2.BaseLoader") -> "jinja2.Environment": 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: def url_for(context: dict, name: str, **path_params: typing.Any) -> str:
request: Request = context["request"] request: Request = context["request"]
return request.app.url_path_for(name, **path_params) return request.app.url_path_for(name, **path_params)