Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
julianlocke committed Jan 5, 2024
1 parent 01f17c1 commit 9cfc95f
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions stone/backends/swift_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ def _generate_routes(self, namespace):
template_globals['objc_init_args_to_swift'] = self._objc_init_args_to_swift
template_globals['objc_result_from_swift'] = self._objc_result_from_swift
template_globals['objc_no_defualts_func_args'] = self._objc_no_defualts_func_args
template_globals['objc_app_auth_route_wrapper_already_defined'] = self._objc_app_auth_route_wrapper_already_defined
template_globals['objc_app_auth_route_wrapper_already_defined'] = \

Check warning on line 215 in stone/backends/swift_client.py

View check run for this annotation

Codecov / codecov/patch

stone/backends/swift_client.py#L215

Added line #L215 was not covered by tests
self._objc_app_auth_route_wrapper_already_defined

ns_class = self._class_name(fmt_class(namespace.name))

Expand Down Expand Up @@ -254,14 +255,16 @@ def _generate_request_boxes(self, api):
template.globals = template_globals

# don't include the default case in the generated switch statement if it's unreachable
include_default_in_switch = len(background_objc_routes) < len(background_compatible_routes)
include_default_in_switch = \

Check warning on line 258 in stone/backends/swift_client.py

View check run for this annotation

Codecov / codecov/patch

stone/backends/swift_client.py#L258

Added line #L258 was not covered by tests
len(background_objc_routes) < len(background_compatible_routes)

output = template.render(

Check warning on line 261 in stone/backends/swift_client.py

View check run for this annotation

Codecov / codecov/patch

stone/backends/swift_client.py#L261

Added line #L261 was not covered by tests
background_compatible_routes=background_compatible_routes,
background_objc_routes=background_objc_routes,
class_name=swift_class_name,
include_default_in_switch=include_default_in_switch
)

class_name = 'DBX{}RequestBox'.format(self.args.class_name)
output = template.render(background_compatible_routes=background_compatible_routes,
background_objc_routes=background_objc_routes,
class_name=swift_class_name,
include_default_in_switch=include_default_in_switch
)
file_name = 'DBX{}RequestBox.swift'.format(self.args.class_name)
self._write_output_in_target_folder(output,
file_name,
Expand Down Expand Up @@ -298,7 +301,9 @@ def _generate_reconnection_helpers(self, api):
background_compatible_namespace_route_pairs=background_compatible_pairs
)

self._write_output_in_target_folder(output_from_parsed_template, '{}.swift'.format(class_name))
self._write_output_in_target_folder(

Check warning on line 304 in stone/backends/swift_client.py

View check run for this annotation

Codecov / codecov/patch

stone/backends/swift_client.py#L304

Added line #L304 was not covered by tests
output_from_parsed_template, '{}.swift'.format(class_name)
)

def _background_compatible_routes(self, api):
background_compatible_pairs = self._background_compatible_namespace_route_pairs(api)
Expand Down Expand Up @@ -342,13 +347,14 @@ def _valid_route_for_auth_type(self, route):
client_auth_type = self.args.auth_type

# if building the app client, only include app auth routes
# if building the user or team client, include routes of all auth types except app auth exclusive routes
# if building the user or team client, include routes of all auth types except
# app auth exclusive routes

is_app_auth_only_route = route_auth_type == 'app'
route_auth_types_include_app = 'app' in route_auth_type

Check warning on line 354 in stone/backends/swift_client.py

View check run for this annotation

Codecov / codecov/patch

stone/backends/swift_client.py#L353-L354

Added lines #L353 - L354 were not covered by tests

if client_auth_type == 'app':
return is_app_auth_only_route or route_auth_types_include_app
return is_app_auth_only_route or route_auth_types_include_app

Check warning on line 357 in stone/backends/swift_client.py

View check run for this annotation

Codecov / codecov/patch

stone/backends/swift_client.py#L357

Added line #L357 was not covered by tests
else:
return not is_app_auth_only_route

Check warning on line 359 in stone/backends/swift_client.py

View check run for this annotation

Codecov / codecov/patch

stone/backends/swift_client.py#L359

Added line #L359 was not covered by tests

Expand Down Expand Up @@ -565,7 +571,8 @@ def _background_compatible_routes_for_objc_requests(self, api):
objc_class_to_route = {}
for namespace in namespaces:
for route in namespace.routes:
if self._background_session_route_style(route) is not None and self._valid_route_for_auth_type(route):
bg_route_style = self._background_session_route_style(route)

Check warning on line 574 in stone/backends/swift_client.py

View check run for this annotation

Codecov / codecov/patch

stone/backends/swift_client.py#L574

Added line #L574 was not covered by tests
if bg_route_style is not None and self._valid_route_for_auth_type(route):
args_data = self._route_client_args(route)[0]
objc_class = self._fmt_route_objc_class(namespace, route, args_data)
objc_class_to_route[objc_class] = [namespace, route, args_data]
Expand Down

0 comments on commit 9cfc95f

Please sign in to comment.