Skip to content

Commit

Permalink
Fix some code quality and bug-risk issues
Browse files Browse the repository at this point in the history
  • Loading branch information
pnijhara committed Apr 26, 2020
1 parent 95e2f66 commit 0e4aa4c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
15 changes: 15 additions & 0 deletions .deepsource.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version = 1

test_patterns = ["tests/**"]

exclude_patterns = [
"examples/**",
"benchmarks/**"
]

[[analyzers]]
name = "python"
enabled = true

[analyzers.meta]
runtime_version = "3.x.x"
2 changes: 1 addition & 1 deletion hug/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def add_exception_handler(self, exception_type, error_handler, versions=(None,))

for version in versions:
placement = self._exception_handlers.setdefault(version, OrderedDict())
placement[exception_type] = (error_handler,) + placement.get(exception_type, tuple())
placement[exception_type] = (error_handler,) + placement.get(exception_type, ())

def extend(self, http_api, route="", base_url="", **kwargs):
"""Adds handlers from a different Hug API to this one - to create a single API"""
Expand Down
8 changes: 3 additions & 5 deletions hug/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def __init__(self, route, function):
self.parameters = tuple(route["parameters"])
self.all_parameters = set(route["parameters"])
self.required = tuple(
[parameter for parameter in self.parameters if parameter not in self.defaults]
parameter for parameter in self.parameters if parameter not in self.defaults
)

if "map_params" in route:
Expand All @@ -204,10 +204,8 @@ def __init__(self, route, function):
self.all_parameters.add(interface_name)
if internal_name in self.required:
self.required = tuple(
[
interface_name if param == internal_name else param
for param in self.required
]
interface_name if param == internal_name else param
for param in self.required
)

reverse_mapping = {
Expand Down

0 comments on commit 0e4aa4c

Please sign in to comment.