File tree Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -553,6 +553,7 @@ def build_check_arguments(
553
553
args .append ("--exit-zero" )
554
554
# Use the json formatting for easier evaluation
555
555
args .append ("--output-format=json" )
556
+ args .append ("--extension=ipynb:python" )
556
557
if fix :
557
558
args .append ("--fix" )
558
559
else :
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ readme = "README.md"
13
13
requires-python = " >=3.7"
14
14
license = {text = " MIT" }
15
15
dependencies = [
16
- " ruff>=0.1.0 , <0.2.0" ,
16
+ " ruff>=0.1.5 , <0.2.0" ,
17
17
" python-lsp-server" ,
18
18
" cattrs!=23.2.1" ,
19
19
" lsprotocol>=2022.0.0a1" ,
Original file line number Diff line number Diff line change @@ -182,6 +182,7 @@ def f():
182
182
"--quiet" ,
183
183
"--exit-zero" ,
184
184
"--output-format=json" ,
185
+ "--extension=ipynb:python" ,
185
186
"--no-fix" ,
186
187
"--force-exclude" ,
187
188
f"--stdin-filename={ os .path .join (workspace .root_path , '__init__.py' )} " ,
@@ -243,3 +244,23 @@ def f():
243
244
assert diag ["code" ] != "F401"
244
245
245
246
os .unlink (os .path .join (workspace .root_path , "pyproject.toml" ))
247
+
248
+
249
+ def test_notebook_input (workspace ):
250
+ doc_str = r"""
251
+ print('hi')
252
+ import os
253
+ def f():
254
+ a = 2
255
+ """
256
+ # attribute the python code to a notebook file name per jupyterlab-lsp
257
+ doc_uri = uris .from_fs_path (os .path .join (workspace .root_path , "Untitled.ipynb" ))
258
+ workspace .put_document (doc_uri , doc_str )
259
+ doc = workspace .get_document (doc_uri )
260
+
261
+ diags = ruff_lint .pylsp_lint (workspace , doc )
262
+ diag_codes = [diag ["code" ] for diag in diags ]
263
+ assert "E999" not in diag_codes
264
+ assert "E402" in diag_codes
265
+ assert "F401" in diag_codes
266
+ assert "F841" in diag_codes
You can’t perform that action at this time.
0 commit comments