@@ -18,7 +18,7 @@ def __init__(self, url="https://bpsapi.rajtech.me/"):
1818 # /latest endpoint
1919 def latest (self , category : str or int ) -> dict | None :
2020 """The `/latest` endpoint returns the latest circular from a particular category"""
21- if type (category ) == int :
21+ if type (category ) is int :
2222 category = int (category )
2323
2424 if not 1 < category < 100 :
@@ -39,7 +39,7 @@ def latest(self, category: str or int) -> dict | None:
3939 return json ['data' ]
4040
4141 # /list endpoint
42- def list_ (self , category : str or int , amount : int = - 1 ) -> list | None :
42+ def list_ (self , category : str or int , amount : int = None ) -> list | None :
4343 """The `/list` endpoint returns a list of circulars from a particular category"""
4444 if type (category ) is int :
4545 if not 1 < category < 100 :
@@ -49,8 +49,8 @@ def list_(self, category: str or int, amount: int = -1) -> list | None:
4949 if category not in self .categories :
5050 raise ValueError ("Invalid category Name" )
5151
52- if amount < - 1 :
53- amount = - 1
52+ if amount < 1 :
53+ amount = None
5454
5555 request = requests .get (f"{ self .url } list/{ category } " )
5656 json = request .json ()
@@ -60,7 +60,7 @@ def list_(self, category: str or int, amount: int = -1) -> list | None:
6060 except KeyError :
6161 raise ConnectionError ("Invalid API Response" )
6262 if json ['http_status' ] == 200 :
63- return json ['data' ] if amount == - 1 else json [ 'data' ] [:amount ]
63+ return json ['data' ][:amount ]
6464
6565 def search (self , query : str or int , amount : int = 1 ) -> dict | None :
6666 """The `/search` endpoint lets you search for a circular by its name or ID"""
@@ -230,7 +230,7 @@ def check(self) -> list[dict] | list[None]:
230230 {
231231 'id' : i [0 ],
232232 'title' : i [1 ],
233- 'link' : [2 ]
233+ 'link' : i [2 ]
234234 }
235235 for i in new_circular_objects
236236 ]
@@ -247,14 +247,12 @@ class CircularCheckerGroup:
247247 def __init__ (self , * args , ** kwargs ):
248248 self ._checkers = []
249249
250- self .debug = bool (kwargs .get ("debug" ))
251-
252250 for arg in args :
253251 if type (arg ) is not CircularChecker :
254252 raise ValueError ("Invalid CircularChecker Object" )
255253 self ._checkers .append (arg )
256254
257- if self . debug :
255+ if bool ( kwargs . get ( " debug" )) :
258256 self .checkers = self ._checkers
259257
260258 def add (self , checker : CircularChecker , * args : CircularChecker ):
@@ -264,12 +262,11 @@ def add(self, checker: CircularChecker, *args: CircularChecker):
264262 raise ValueError ("Invalid CircularChecker Object" )
265263 self ._checkers .append (arg )
266264
267- def create (self , category , url : str = "https://bpsapi.rajtech.me/" , cache_method = None , debug : bool = False ,
268- ** kwargs ):
269- checker = CircularChecker (category , url , cache_method , debug , ** kwargs )
265+ def create (self , category , url : str = "https://bpsapi.rajtech.me/" , cache_method = None , ** kwargs ):
266+ checker = CircularChecker (category , url , cache_method , ** kwargs )
270267 self ._checkers .append (checker )
271268
272- def check (self ) -> dict [list [dict ]] :
269+ def check (self ) -> dict [list [dict ], ...] | dict :
273270 return_dict = {}
274271 for checker in self ._checkers :
275272 return_dict [checker .category ] = checker .check ()
@@ -279,7 +276,7 @@ def refresh_cache(self):
279276 for checker in self ._checkers :
280277 checker .refresh_cache ()
281278
282- def get_cache (self ) -> dict [list [list ]]:
279+ def get_cache (self ) -> dict [list [list ]] | dict :
283280 return_dict = {}
284281 for checker in self ._checkers :
285282 return_dict [checker .category ] = checker .get_cache ()
0 commit comments