Skip to content

[4.4] Fix suppression of warnings for internal API usage #1040

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

Merged
merged 2 commits into from
Apr 12, 2024
Merged
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
18 changes: 8 additions & 10 deletions neo4j/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,12 @@ def _consume(cls, data):
config[key] = value
return cls(config)

def __update(self, data):
def __update(self, data, warn=True):
data_dict = dict(iter_items(data))

def set_attr(k, v):
if k in self.keys():
if k in self._deprecated_options():
if warn and k in self._deprecated_options():
deprecation_warn("The '{}' config key is "
"deprecated".format(k))
setattr(self, k, v)
Expand All @@ -164,10 +164,11 @@ def set_attr(k, v):
if k0 in data_dict:
raise ValueError("Cannot specify both '{}' and '{}' in "
"config".format(k0, k))
deprecation_warn(
"The '{}' config key is deprecated, please use "
"'{}' instead".format(k, k0)
)
if warn:
deprecation_warn(
"The '{}' config key is deprecated, please use "
"'{}' instead".format(k, k0)
)
set_attr(k0, v)
else:
raise AttributeError(k)
Expand All @@ -189,10 +190,7 @@ def set_attr(k, v):
def __init__(self, *args, **kwargs):
for arg in args:
if isinstance(arg, Config):
with warnings.catch_warnings():
warnings.filterwarnings("ignore",
category=DeprecationWarning)
self.__update(arg)
self.__update(arg, warn=False)
else:
self.__update(arg)
self.__update(kwargs)
Expand Down