From 2c380218ecbd256ff555e0ff2c406e12ee839d8c Mon Sep 17 00:00:00 2001 From: Juliya Smith Date: Wed, 11 Dec 2024 12:28:21 -0600 Subject: [PATCH] refactor: set req head in ctor --- src/ape/managers/config.py | 6 +++++- src/ape/utils/basemodel.py | 5 +---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/ape/managers/config.py b/src/ape/managers/config.py index 92d94bf53a..f96ad38ec6 100644 --- a/src/ape/managers/config.py +++ b/src/ape/managers/config.py @@ -16,7 +16,7 @@ ) from ape.utils.misc import log_instead_of_fail from ape.utils.os import create_tempdir, in_tempdir -from ape.utils.rpc import RPCHeaders +from ape.utils.rpc import USER_AGENT, RPCHeaders if TYPE_CHECKING: from ethpm_types import PackageManifest @@ -39,6 +39,10 @@ def __init__(self, data_folder: Optional[Path] = None, request_header: Optional[ else: self.DATA_FOLDER = data_folder or Path.home() / ".ape" + request_header = request_header or { + "User-Agent": USER_AGENT, + "Content-Type": "application/json", + } self.REQUEST_HEADER = request_header or {} def __ape_extra_attributes__(self): diff --git a/src/ape/utils/basemodel.py b/src/ape/utils/basemodel.py index ba92547759..3d80bf1e48 100644 --- a/src/ape/utils/basemodel.py +++ b/src/ape/utils/basemodel.py @@ -17,7 +17,6 @@ from ape.exceptions import ApeAttributeError, ApeIndexError, ProviderNotConnectedError from ape.logging import logger from ape.utils.misc import log_instead_of_fail, raises_not_implemented -from ape.utils.rpc import USER_AGENT if TYPE_CHECKING: from pydantic.main import Model @@ -173,9 +172,7 @@ def config_manager(cls) -> "ConfigManager": The :class:`~ape.managers.config.ConfigManager`. """ config = import_module("ape.managers.config") - return config.ConfigManager( - request_header={"User-Agent": USER_AGENT, "Content-Type": "application/json"}, - ) + return config.ConfigManager() @manager_access def conversion_manager(cls) -> "ConversionManager":