Skip to content

Commit

Permalink
refactor: set req head in ctor
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Dec 11, 2024
1 parent 6ca9d38 commit 2c38021
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/ape/managers/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down
5 changes: 1 addition & 4 deletions src/ape/utils/basemodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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":
Expand Down

0 comments on commit 2c38021

Please sign in to comment.