From b872bd3bc1f7f219a7557e5161b26034d8bbfe43 Mon Sep 17 00:00:00 2001 From: Justin Jeffery Date: Thu, 30 Dec 2021 10:48:47 -0500 Subject: [PATCH] fix: dont env --- ipfabric/client.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ipfabric/client.py b/ipfabric/client.py index c720395..1b8af94 100644 --- a/ipfabric/client.py +++ b/ipfabric/client.py @@ -23,6 +23,12 @@ class Config: env_file = '.env' env_file_encoding = 'utf-8' + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_val, exc_tb): + pass + def check_format(func): """ @@ -53,10 +59,10 @@ def __init__( :param vargs: list: List to pass to httpx :param kwargs: dict: Keyword args to pass to httpx """ - settings = Settings() - kwargs['base_url'] = urljoin(base_url or settings.ipf_url, "api/v1/") - kwargs['verify'] = kwargs.get('verify', None) or settings.ipf_verify - token = token or settings.ipf_token + with Settings() as settings: + kwargs['base_url'] = urljoin(base_url or settings.ipf_url, "api/v1/") + kwargs['verify'] = kwargs.get('verify') if 'verify' in kwargs else settings.ipf_verify + token = token or settings.ipf_token if not kwargs['base_url']: raise RuntimeError("IP Fabric base_url not provided or IPF_URL not set")