File tree Expand file tree Collapse file tree 5 files changed +45
-15
lines changed
Expand file tree Collapse file tree 5 files changed +45
-15
lines changed Original file line number Diff line number Diff line change @@ -111,7 +111,7 @@ jobs:
111111 pytest -vv -W default || pytest -vv -W default --lf
112112
113113 check_links :
114- name : Make SDist
114+ name : Check Links
115115 runs-on : ubuntu-latest
116116 timeout-minutes : 10
117117 steps :
Original file line number Diff line number Diff line change 2222 args : ["--line-length", "100"]
2323
2424 - repo : https://github.com/PyCQA/isort
25- rev : 5.10.1
25+ rev : 5.12.0
2626 hooks :
2727 - id : isort
2828 files : \.py$
Original file line number Diff line number Diff line change @@ -26,19 +26,24 @@ def get_loader(obj, logger=None):
2626 underscore prefix.
2727 """
2828 try :
29- func = getattr (obj , "_load_jupyter_server_extension" ) # noqa B009
29+ return getattr (obj , "_load_jupyter_server_extension" ) # noqa B009
3030 except AttributeError :
31- func = getattr (obj , "load_jupyter_server_extension" , None )
32- warnings .warn (
33- "A `_load_jupyter_server_extension` function was not "
34- "found in {name!s}. Instead, a `load_jupyter_server_extension` "
35- "function was found and will be used for now. This function "
36- "name will be deprecated in future releases "
37- "of Jupyter Server." .format (name = obj ),
38- DeprecationWarning ,
39- )
40- except Exception :
41- raise ExtensionLoadingError ("_load_jupyter_server_extension function was not found." )
31+ pass
32+
33+ try :
34+ func = getattr (obj , "load_jupyter_server_extension" ) # noqa B009
35+ except AttributeError :
36+ msg = "_load_jupyter_server_extension function was not found."
37+ raise ExtensionLoadingError (msg ) from None
38+
39+ warnings .warn (
40+ "A `_load_jupyter_server_extension` function was not "
41+ "found in {name!s}. Instead, a `load_jupyter_server_extension` "
42+ "function was found and will be used for now. This function "
43+ "name will be deprecated in future releases "
44+ "of Jupyter Server." .format (name = obj ),
45+ DeprecationWarning ,
46+ )
4247 return func
4348
4449
Original file line number Diff line number Diff line change 1+ """A mock extension named `mockext_py` for testing purposes.
2+ """
3+ # Function that makes these extensions discoverable
4+ # by the test functions.
5+
6+
7+ def _jupyter_server_extension_paths ():
8+ return [{"module" : "tests.extension.mockextensions.mockext_deprecated" }]
9+
10+
11+ def load_jupyter_server_extension (serverapp ):
12+ pass
Original file line number Diff line number Diff line change 11import pytest
22
3- from jupyter_server .extension .utils import validate_extension
3+ from jupyter_server .extension .utils import (
4+ ExtensionLoadingError ,
5+ get_loader ,
6+ validate_extension ,
7+ )
8+ from tests .extension .mockextensions import mockext_deprecated , mockext_sys
49
510# Use ServerApps environment because it monkeypatches
611# jupyter_core.paths and provides a config directory
@@ -17,3 +22,11 @@ def test_validate_extension():
1722 assert validate_extension ("tests.extension.mockextensions.mockext_user" )
1823 # enabled at Python
1924 assert validate_extension ("tests.extension.mockextensions.mockext_py" )
25+
26+
27+ def test_get_loader ():
28+ assert get_loader (mockext_sys ) == mockext_sys ._load_jupyter_server_extension
29+ with pytest .deprecated_call ():
30+ assert get_loader (mockext_deprecated ) == mockext_deprecated .load_jupyter_server_extension
31+ with pytest .raises (ExtensionLoadingError ):
32+ get_loader (object ())
You can’t perform that action at this time.
0 commit comments