diff --git a/.deepsource.toml b/.deepsource.toml new file mode 100644 index 00000000..3023c026 --- /dev/null +++ b/.deepsource.toml @@ -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" \ No newline at end of file diff --git a/hug/api.py b/hug/api.py index 7951d6e0..1bd24fae 100644 --- a/hug/api.py +++ b/hug/api.py @@ -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""" diff --git a/hug/interface.py b/hug/interface.py index fbd31619..fe9f8f1c 100644 --- a/hug/interface.py +++ b/hug/interface.py @@ -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: @@ -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 = {