Skip to content

Commit d527b3f

Browse files
authored
Merge pull request #47 from martinRenou/fix_jupyter_server_deprecation_warning
Fix deprecation warning when importing jupyter_server.transutils._
2 parents 0e30d80 + 603865d commit d527b3f

File tree

4 files changed

+24
-25
lines changed

4 files changed

+24
-25
lines changed

nbclassic/notebook/handlers.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
url_escape,
2323
ensure_async
2424
)
25-
from jupyter_server.transutils import _
25+
from jupyter_server.transutils import _i18n
2626

2727

2828
def get_frontend_exporters():
@@ -52,7 +52,7 @@ def get_frontend_exporters():
5252

5353
# Ensure export_from_notebook is explicitly defined & not inherited
5454
if ux_name is not None and ux_name != super_uxname:
55-
display = _('{} ({})'.format(ux_name,
55+
display = _i18n('{} ({})'.format(ux_name,
5656
exporter_instance.file_extension))
5757
frontend_exporters.append(ExporterInfo(name, display))
5858

@@ -117,4 +117,3 @@ def get(self, path):
117117
default_handlers = [
118118
(r"/notebooks%s" % path_regex, NotebookHandler),
119119
]
120-

nbclassic/notebookapp.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
)
4343

4444
from jupyter_server.log import log_request
45-
from jupyter_server.transutils import _
45+
from jupyter_server.transutils import _i18n
4646
from jupyter_server.serverapp import (
4747
ServerApp,
4848
random_ports,
@@ -71,7 +71,7 @@
7171
aliases = {}
7272
flags['no-browser']=(
7373
{'ServerApp' : {'open_browser' : False}},
74-
_("Don't open the notebook in a browser after startup.")
74+
_i18n("Don't open the notebook in a browser after startup.")
7575
)
7676
flags['no-mathjax']=(
7777
{'NotebookApp' : {'enable_mathjax' : False}},
@@ -87,7 +87,7 @@
8787

8888
flags['allow-root']=(
8989
{'ServerApp' : {'allow_root' : True}},
90-
_("Allow the notebook to be run from root user.")
90+
_i18n("Allow the notebook to be run from root user.")
9191
)
9292

9393
aliases.update({
@@ -120,7 +120,7 @@ class NotebookApp(
120120

121121
name = 'notebook'
122122
version = __version__
123-
description = _("""The Jupyter HTML Notebook.
123+
description = _i18n("""The Jupyter HTML Notebook.
124124
125125
This launches a Tornado based HTML Notebook Server that serves up an HTML5/Javascript Notebook client.""")
126126

@@ -144,7 +144,7 @@ class NotebookApp(
144144
).tag(config=True)
145145

146146
static_custom_path = List(Unicode(),
147-
help=_("""Path to search for custom.js, css""")
147+
help=_i18n("""Path to search for custom.js, css""")
148148
)
149149

150150
@default('static_custom_path')
@@ -156,7 +156,7 @@ def _default_static_custom_path(self):
156156
]
157157

158158
extra_nbextensions_path = List(Unicode(), config=True,
159-
help=_("""extra paths to look for Javascript notebook extensions""")
159+
help=_i18n("""extra paths to look for Javascript notebook extensions""")
160160
)
161161

162162
@property
@@ -194,9 +194,9 @@ def _prepare_templates(self):
194194
def initialize_settings(self):
195195
"""Add settings to the tornado app."""
196196
if self.ignore_minified_js:
197-
self.log.warning(_("""The `ignore_minified_js` flag is deprecated and no longer works."""))
198-
self.log.warning(_("""Alternatively use `%s` when working on the notebook's Javascript and LESS""") % 'npm run build:watch')
199-
warnings.warn(_("The `ignore_minified_js` flag is deprecated and will be removed in Notebook 6.0"), DeprecationWarning)
197+
self.log.warning(_i18n("""The `ignore_minified_js` flag is deprecated and no longer works."""))
198+
self.log.warning(_i18n("""Alternatively use `%s` when working on the notebook's Javascript and LESS""") % 'npm run build:watch')
199+
warnings.warn(_i18n("The `ignore_minified_js` flag is deprecated and will be removed in Notebook 6.0"), DeprecationWarning)
200200

201201
settings = dict(
202202
static_custom_path=self.static_custom_path,

nbclassic/traits.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@
99
__version__,
1010
)
1111
from jupyter_core.paths import jupyter_path
12-
from jupyter_server.transutils import _
12+
from jupyter_server.transutils import _i18n
1313
from jupyter_server.utils import url_path_join
1414

1515

1616
class NotebookAppTraits(HasTraits):
1717

1818
ignore_minified_js = Bool(False,
1919
config=True,
20-
help=_('Deprecated: Use minified JS file or not, mainly use during dev to avoid JS recompilation'),
20+
help=_i18n('Deprecated: Use minified JS file or not, mainly use during dev to avoid JS recompilation'),
2121
)
2222

2323

2424
jinja_environment_options = Dict(config=True,
25-
help=_("Supply extra arguments that will be passed to Jinja environment."))
25+
help=_i18n("Supply extra arguments that will be passed to Jinja environment."))
2626

2727
jinja_template_vars = Dict(
2828
config=True,
29-
help=_("Extra variables to supply to jinja templates when rendering."),
29+
help=_i18n("Extra variables to supply to jinja templates when rendering."),
3030
)
3131

3232
enable_mathjax = Bool(True, config=True,
@@ -59,7 +59,7 @@ def static_file_path(self):
5959
return self.extra_static_paths + [DEFAULT_STATIC_FILES_PATH]
6060

6161
static_custom_path = List(Unicode(),
62-
help=_("""Path to search for custom.js, css""")
62+
help=_i18n("""Path to search for custom.js, css""")
6363
)
6464

6565
@default('static_custom_path')
@@ -71,7 +71,7 @@ def _default_static_custom_path(self):
7171
]
7272

7373
extra_template_paths = List(Unicode(), config=True,
74-
help=_("""Extra paths to search for serving jinja templates.
74+
help=_i18n("""Extra paths to search for serving jinja templates.
7575
7676
Can be used to override templates from notebook.templates.""")
7777
)
@@ -82,7 +82,7 @@ def template_file_path(self):
8282
return self.extra_template_paths + DEFAULT_TEMPLATE_PATH_LIST
8383

8484
extra_nbextensions_path = List(Unicode(), config=True,
85-
help=_("""extra paths to look for Javascript notebook extensions""")
85+
help=_i18n("""extra paths to look for Javascript notebook extensions""")
8686
)
8787

8888
@property
@@ -124,24 +124,24 @@ def _update_mathjax_url(self, change):
124124
# enable_mathjax=False overrides mathjax_url
125125
self.mathjax_url = u''
126126
else:
127-
self.log.info(_("Using MathJax: %s"), new)
127+
self.log.info(_i18n("Using MathJax: %s"), new)
128128

129129
mathjax_config = Unicode("TeX-AMS-MML_HTMLorMML-full,Safe", config=True,
130-
help=_("""The MathJax.js configuration file that is to be used.""")
130+
help=_i18n("""The MathJax.js configuration file that is to be used.""")
131131
)
132132

133133
@observe('mathjax_config')
134134
def _update_mathjax_config(self, change):
135-
self.log.info(_("Using MathJax configuration file: %s"), change['new'])
135+
self.log.info(_i18n("Using MathJax configuration file: %s"), change['new'])
136136

137137
quit_button = Bool(True, config=True,
138138
help="""If True, display a button in the dashboard to quit
139139
(shutdown the notebook server)."""
140140
)
141141

142142
nbserver_extensions = Dict({}, config=True,
143-
help=(_("Dict of Python modules to load as notebook server extensions."
143+
help=(_i18n("Dict of Python modules to load as notebook server extensions."
144144
"Entry values can be used to enable and disable the loading of"
145145
"the extensions. The extensions will be loaded in alphabetical "
146146
"order."))
147-
)
147+
)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
python_requires='>=3.6',
5656
include_package_data=True,
5757
install_requires = [
58-
'jupyter_server~=1.4',
58+
'jupyter_server~=1.5',
5959
'notebook<7',
6060
],
6161
entry_points = {

0 commit comments

Comments
 (0)