-
Notifications
You must be signed in to change notification settings - Fork 505
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
Update blacklist
and whitelist
keywords
#1367
Conversation
@@ -10,6 +10,9 @@ | |||
from ._version import __version__ # noqa | |||
from .server_extension import _load_jupyter_server_extension # noqa | |||
from .server_extension import load_jupyter_server_extension # noqa | |||
import warnings | |||
|
|||
warnings.filterwarnings("default", category=DeprecationWarning, module="traitlets") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmmh, Maybe we should not do that and fix the deprecation warnings instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, the DeprecationWarning
is hidden by default https://docs.python.org/3/library/exceptions.html#DeprecationWarning
file_whitelist = List( | ||
Unicode(), | ||
[r".*\.(png|jpg|gif|svg)"], | ||
config=True, | ||
help="""Deprecated, use `file_allowlist`""", | ||
) | ||
|
||
@validate("file_whitelist") | ||
def _valid_file_whitelist(self, proposal): | ||
warn( | ||
"Deprecated, use VoilaConfiguration.file_allowlist instead.", | ||
DeprecationWarning, | ||
stacklevel=2, | ||
) | ||
return proposal["value"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May I suggest another approach for this?
@property
def file_whitelist(self):
warn(
"Deprecated, use VoilaConfiguration.file_allowlist instead.",
DeprecationWarning,
stacklevel=2,
)
return self.file_allowlist
@file_whitelist.setter
def file_whitelist(self, value):
warn(
"Deprecated, use VoilaConfiguration.file_allowlist instead.",
DeprecationWarning,
stacklevel=2,
)
self.file_allowlist = value
That way we can get rid of the
warnings.filterwarnings("default", category=DeprecationWarning, module="traitlets")
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My suggestion applies if we consider going from a traitlet to a property is not backward incompatible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By doing so, users can not set the allow/deny list from the CLI or the voila.json
file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point 👍🏽
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
References
Closes #1366
Code changes
User-facing changes
blacklist
are replaced bydenylist
whitelist
are replaced byallowlist
DeprecationWarning
message is raised on using the old keywords.Backwards-incompatible changes
N/A