Skip to content

Commit 11eaa0e

Browse files
author
ExpDev07
committed
cleanup imports
1 parent 7efb2f0 commit 11eaa0e

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

app/main.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
"""
22
app.main.py
33
"""
4-
import datetime as dt
5-
import enum
64
import logging
75
import os
86
import reprlib
7+
import datetime as dt
98

10-
import fastapi
119
import pydantic
1210
import uvicorn
1311

14-
from typing import Dict, List
12+
from fastapi import FastAPI
13+
from fastapi import Request, Response
14+
15+
from fastapi.responses import JSONResponse
1516

1617
from fastapi.middleware.wsgi import WSGIMiddleware
1718
from fastapi.middleware.cors import CORSMiddleware
@@ -27,7 +28,7 @@
2728
# ############
2829
LOGGER = logging.getLogger('api')
2930

30-
APP = fastapi.FastAPI(
31+
APP = FastAPI(
3132
title='Coronavirus Tracker',
3233
description='API for tracking the global coronavirus (COVID-19, SARS-CoV-2) outbreak. Project page: https://github.com/ExpDev07/coronavirus-tracker-api.',
3334
version='2.0.1',
@@ -50,7 +51,7 @@
5051

5152
# TODO this could probably just be a FastAPI dependency.
5253
@APP.middleware('http')
53-
async def add_datasource(request: fastapi.Request, call_next):
54+
async def add_datasource(request: Request, call_next):
5455
"""
5556
Attach the data source to the request.state.
5657
"""
@@ -59,7 +60,7 @@ async def add_datasource(request: fastapi.Request, call_next):
5960

6061
# Abort with 404 if source cannot be found.
6162
if not source:
62-
return fastapi.Response('The provided data-source was not found.', status_code=404)
63+
return Response('The provided data-source was not found.', status_code=404)
6364

6465
# Attach source to request.
6566
request.state.source = source
@@ -77,12 +78,12 @@ async def add_datasource(request: fastapi.Request, call_next):
7778

7879
@APP.exception_handler(pydantic.error_wrappers.ValidationError)
7980
async def handle_validation_error(
80-
request: fastapi.Request, exc: pydantic.error_wrappers.ValidationError
81+
request: Request, exc: pydantic.error_wrappers.ValidationError
8182
):
8283
"""
8384
Handles validation errors.
8485
"""
85-
return fastapi.responses.JSONResponse({'message': exc.errors()}, status_code=422)
86+
return JSONResponse({'message': exc.errors()}, status_code=422)
8687

8788

8889
# ################

0 commit comments

Comments
 (0)