Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: set ConfigManager.request_header in ctor instead of in module namespace #2409

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading