Remove assert statements from base Service class

The 2nd assert statement is completely unnecessary, and the first one can be resolved by using it in an if instead.
This commit is contained in:
rlaphoenix 2023-02-10 19:49:19 +00:00
parent dbe52cf273
commit a8f3975f7e
1 changed files with 6 additions and 4 deletions

View File

@ -30,14 +30,15 @@ class Service(metaclass=ABCMeta):
def __init__(self, ctx: click.Context):
self.config = ctx.obj.config
assert ctx.parent is not None
assert ctx.parent.parent is not None
self.log = logging.getLogger(self.__class__.__name__)
self.session = self.get_session()
self.cache = Cacher(self.__class__.__name__)
self.proxy = ctx.parent.params["proxy"]
if ctx.parent:
self.proxy = ctx.parent.params["proxy"]
else:
self.proxy = None
if not self.proxy and self.GEOFENCE:
# no explicit proxy, let's get one to GEOFENCE if needed
current_region = get_ip_info(self.session)["country"].lower()
@ -50,6 +51,7 @@ class Service(metaclass=ABCMeta):
if self.proxy:
self.log.info(f" + {self.proxy} (from {proxy_provider.__class__.__name__})")
break
if self.proxy:
self.session.proxies.update({"all": self.proxy})
proxy_parse = urlparse(self.proxy)