2626"""
2727
2828import ipaddress
29- from typing import cast , Dict , List , Optional , Type , Union
29+ from typing import Any , cast , List , Optional , Type , Union
3030
3131import requests
3232from requests .models import Response
@@ -173,24 +173,15 @@ def _response_for(
173173 body = self ._handle_success (response , uri )
174174 return model_class (body , locales = self ._locales )
175175
176- def _user_agent (self ) -> str :
176+ @staticmethod
177+ def _user_agent () -> str :
177178 return "GeoIP2 Python Client v%s (%s)" % (
178179 geoip2 .__version__ ,
179180 default_user_agent (),
180181 )
181182
182- def _handle_success (
183- self , response : Response , uri : str
184- ) -> Dict [
185- str ,
186- Union [
187- Dict [str , Union [str , int , Dict [str , str ]]],
188- Dict [str , int ],
189- Dict [str , Union [int , bool , str , Dict [str , str ]]],
190- Dict [str , Union [int , float , str ]],
191- Dict [str , str ],
192- ],
193- ]:
183+ @staticmethod
184+ def _handle_success (response : Response , uri : str ) -> Any :
194185 try :
195186 return response .json ()
196187 except ValueError as ex :
@@ -247,8 +238,9 @@ def _exception_for_4xx_status(
247238 uri ,
248239 )
249240
241+ @staticmethod
250242 def _exception_for_web_service_error (
251- self , message : str , code : str , status : int , uri : str
243+ message : str , code : str , status : int , uri : str
252244 ) -> Union [
253245 AuthenticationError ,
254246 AddressNotFoundError ,
@@ -274,14 +266,16 @@ def _exception_for_web_service_error(
274266
275267 return InvalidRequestError (message , code , status , uri )
276268
277- def _exception_for_5xx_status (self , status : int , uri : str ) -> HTTPError :
269+ @staticmethod
270+ def _exception_for_5xx_status (status : int , uri : str ) -> HTTPError :
278271 return HTTPError (
279272 "Received a server error (%(status)i) for " "%(uri)s" % locals (),
280273 status ,
281274 uri ,
282275 )
283276
284- def _exception_for_non_200_status (self , status : int , uri : str ) -> HTTPError :
277+ @staticmethod
278+ def _exception_for_non_200_status (status : int , uri : str ) -> HTTPError :
285279 return HTTPError (
286280 "Received a very surprising HTTP status "
287281 "(%(status)i) for %(uri)s" % locals (),
0 commit comments