File fix-invalid-escape-sequences-pr-869.patch of Package python-hug
From acd3917f5fa9ccc0d53a434474f4a511daf193f5 Mon Sep 17 00:00:00 2001
From: Karthikeyan Singaravelan <tir.karthi@gmail.com>
Date: Sat, 25 Jul 2020 04:32:48 +0000
Subject: [PATCH] Fix deprecation warnings due to invalid escape sequences and
comparison of literals using is.
---
hug/api.py | 2 +-
hug/middleware.py | 2 +-
hug/use.py | 2 +-
tests/test_output_format.py | 4 ++--
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/hug/api.py b/hug/api.py
index 1bd24fae..7179c7a4 100644
--- a/hug/api.py
+++ b/hug/api.py
@@ -55,7 +55,7 @@
-::` ::- VERSION {0}
`::- -::`
-::-` -::-
-\########################################################################/
+\\########################################################################/
Copyright (C) 2016 Timothy Edmund Crosley
Under the MIT License
diff --git a/hug/middleware.py b/hug/middleware.py
index 59f02473..ea522794 100644
--- a/hug/middleware.py
+++ b/hug/middleware.py
@@ -168,7 +168,7 @@ def match_route(self, reqpath):
routes = [route for route, _ in route_dicts.items()]
if reqpath not in routes:
for route in routes: # replace params in route with regex
- reqpath = re.sub("^(/v\d*/?)", "/", reqpath)
+ reqpath = re.sub(r"^(/v\d*/?)", "/", reqpath)
base_url = getattr(self.api.http, "base_url", "")
reqpath = reqpath.replace(base_url, "", 1) if base_url else reqpath
if re.match(re.sub(r"/{[^{}]+}", ".+", route) + "$", reqpath, re.DOTALL):
diff --git a/hug/use.py b/hug/use.py
index a6265e34..24a3f264 100644
--- a/hug/use.py
+++ b/hug/use.py
@@ -182,7 +182,7 @@ def request(
if content_type in input_format:
data = input_format[content_type](data, **content_params)
- status_code = int("".join(re.findall("\d+", response.status)))
+ status_code = int("".join(re.findall(r"\d+", response.status)))
if status_code in self.raise_on:
raise requests.HTTPError("{0} occured for url: {1}".format(response.status, url))
diff --git a/tests/test_output_format.py b/tests/test_output_format.py
index b28e05a3..75d28821 100644
--- a/tests/test_output_format.py
+++ b/tests/test_output_format.py
@@ -368,7 +368,7 @@ def test_json_converter_numpy_types():
ex_np_int_array = numpy.int_([5, 4, 3])
ex_np_float = numpy.float(0.5)
- assert 9 is hug.output_format._json_converter(ex_int)
+ assert 9 == hug.output_format._json_converter(ex_int)
assert [1, 2, 3, 4, 5] == hug.output_format._json_converter(ex_np_array)
assert [5, 4, 3] == hug.output_format._json_converter(ex_np_int_array)
assert 0.5 == hug.output_format._json_converter(ex_np_float)
@@ -411,7 +411,7 @@ def test_json_converter_numpy_types():
for np_type in np_bool_types:
assert True == hug.output_format._json_converter(np_type(True))
for np_type in np_int_types:
- assert 1 is hug.output_format._json_converter(np_type(1))
+ assert 1 == hug.output_format._json_converter(np_type(1))
for np_type in np_float_types:
assert 0.5 == hug.output_format._json_converter(np_type(0.5))
for np_type in np_unicode_types: