@@ -37,8 +37,8 @@ def __init__(
3737 self .crawl_popular_projects = crawl_popular_projects
3838 self .browser_version = browser_version
3939
40- self .cache = diskcache .Cache (str (cache_dir / ' diskcache' ))
41- self .db_path = cache_dir / ' projects.sqlite'
40+ self .cache = diskcache .Cache (str (cache_dir / " diskcache" ))
41+ self .db_path = cache_dir / " projects.sqlite"
4242 self .con = sqlite3 .connect (
4343 self .db_path ,
4444 detect_types = sqlite3 .PARSE_DECLTYPES ,
@@ -51,7 +51,6 @@ def create_app(self) -> fastapi.FastAPI:
5151 _view = self .create_view ()
5252
5353 async def lifespan (app : fastapi .FastAPI ):
54-
5554 async with (
5655 httpx .AsyncClient (timeout = 30 ) as http_client ,
5756 aiosqlite .connect (self .db_path , timeout = 5 ) as db ,
@@ -72,7 +71,9 @@ async def lifespan(app: fastapi.FastAPI):
7271 # convenient for development purposes.
7372 @app .get ("/" )
7473 async def redirect_to_index ():
75- return fastapi .responses .RedirectResponse (url = app .url_path_for ('index' ))
74+ return fastapi .responses .RedirectResponse (
75+ url = app .url_path_for ("index" )
76+ )
7677
7778 yield
7879
@@ -92,7 +93,7 @@ async def catch_exceptions_middleware(request: fastapi.Request, call_next):
9293 detail = f"Internal server error ({ err } )"
9394 # raise
9495 logging .getLogger ("simple_repository_browser.error" ).error (
95- ' Unhandled exception' ,
96+ " Unhandled exception" ,
9697 exc_info = err ,
9798 )
9899 content = _view .error_page (
@@ -104,14 +105,20 @@ async def catch_exceptions_middleware(request: fastapi.Request, call_next):
104105 status_code = status_code ,
105106 )
106107
107- app .middleware (' http' )(catch_exceptions_middleware )
108+ app .middleware (" http" )(catch_exceptions_middleware )
108109
109110 return app
110111
111112 def create_view (self ) -> view .View :
112- return view .View (self .template_paths , self .browser_version , static_files_manifest = self .static_files_manifest )
113+ return view .View (
114+ self .template_paths ,
115+ self .browser_version ,
116+ static_files_manifest = self .static_files_manifest ,
117+ )
113118
114- def create_crawler (self , http_client : httpx .AsyncClient , source : SimpleRepository ) -> crawler .Crawler :
119+ def create_crawler (
120+ self , http_client : httpx .AsyncClient , source : SimpleRepository
121+ ) -> crawler .Crawler :
115122 return crawler .Crawler (
116123 http_client = http_client ,
117124 crawl_popular_projects = self .crawl_popular_projects ,
@@ -120,7 +127,9 @@ def create_crawler(self, http_client: httpx.AsyncClient, source: SimpleRepositor
120127 cache = self .cache ,
121128 )
122129
123- def _repo_from_url (self , url : str , http_client : httpx .AsyncClient ) -> SimpleRepository :
130+ def _repo_from_url (
131+ self , url : str , http_client : httpx .AsyncClient
132+ ) -> SimpleRepository :
124133 if urlparse (url ).scheme in ("http" , "https" ):
125134 return HttpRepository (
126135 url = url ,
@@ -129,7 +138,9 @@ def _repo_from_url(self, url: str, http_client: httpx.AsyncClient) -> SimpleRepo
129138 else :
130139 return LocalRepository (Path (url ))
131140
132- def create_model (self , http_client : httpx .AsyncClient , database : aiosqlite .Connection ) -> model .Model :
141+ def create_model (
142+ self , http_client : httpx .AsyncClient , database : aiosqlite .Connection
143+ ) -> model .Model :
133144 source = MetadataInjector (
134145 self ._repo_from_url (self .repository_url , http_client = http_client ),
135146 http_client = http_client ,
@@ -141,7 +152,9 @@ def create_model(self, http_client: httpx.AsyncClient, database: aiosqlite.Conne
141152 crawler = self .create_crawler (http_client , source ),
142153 )
143154
144- def create_controller (self , view : view .View , model : model .Model ) -> controller .Controller :
155+ def create_controller (
156+ self , view : view .View , model : model .Model
157+ ) -> controller .Controller :
145158 return controller .Controller (
146159 model = model ,
147160 view = view ,
0 commit comments