handle_exception
is not used inside function create_app
221 {'Content-Type': 'application/vnd.api+json'},
222 )
223
224 @app.errorhandler(ErrorResponse)225 def handle_exception(error: ErrorResponse):
226 return error.respond()
227
ratelimit_handler
is not used inside function create_app
213 exc = ErrorResponse('Unknown error')
214 return exc.respond()
215
216 @app.errorhandler(429)217 def ratelimit_handler(error):
218 return make_response(
219 json.dumps({'status': 429, 'title': 'Request Limit Exceeded'}),
internal_server_error
is not used inside function create_app
205 if current_user.is_authenticated:
206 current_user.update_lat()
207
208 @app.errorhandler(500)209 def internal_server_error(error):
210 if app.config['PROPOGATE_ERROR'] is True:
211 exc = ErrorResponse(str(error))
track_user
is not used inside function create_app
200 health.add_check(health_check_migrations)
201
202 # http://stackoverflow.com/questions/26724623/
203 @app.before_request204 def track_user():
205 if current_user.is_authenticated:
206 current_user.update_lat()
get_locale
is not used inside function create_app
84 # Babel
85 babel = Babel(app)
86
87 @babel.localeselector 88 def get_locale():
89 # Try to guess the language from the user accept
90 # header the browser transmits. We support de/fr/en in this
Description
This issue concerns that one or more nested classes/functions have been declared but are nowhere used in the function.
A class or function defined inside a function is only accessible inside its parent function scope. It is recommended either to remove the unused classes and functions as it is a dead code or refactor it to use them.
Note: DeepSource will remove all the unused nested definitions during Autofix.
Bad practice
def run():
def total_time():
return Something
class Runner:
def __init__(time):
pass
Preferred
def run():
def total_time():
return Something
class Runner:
def __init__(time):
...
t = total_time()
bill = Runner(t)
...