Skip to content

Commit

Permalink
Merge pull request #869 from tirkarthi/fix-warnings
Browse files Browse the repository at this point in the history
Fix deprecation warnings due to invalid escape sequences and comparison of literals using is.
  • Loading branch information
timothycrosley authored Aug 10, 2020
2 parents fd408e1 + acd3917 commit 8b5ac00
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion hug/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
-::` ::- VERSION {0}
`::- -::`
-::-` -::-
\########################################################################/
\\########################################################################/
Copyright (C) 2016 Timothy Edmund Crosley
Under the MIT License
Expand Down
2 changes: 1 addition & 1 deletion hug/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion hug/use.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
4 changes: 2 additions & 2 deletions tests/test_output_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 8b5ac00

Please sign in to comment.