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(
553553 args .append ("--exit-zero" )
554554 # Use the json formatting for easier evaluation
555555 args .append ("--output-format=json" )
556+ args .append ("--extension=ipynb:python" )
556557 if fix :
557558 args .append ("--fix" )
558559 else :
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ readme = "README.md"
1313requires-python = " >=3.7"
1414license = {text = " MIT" }
1515dependencies = [
16- " ruff>=0.1.0 , <0.2.0" ,
16+ " ruff>=0.1.5 , <0.2.0" ,
1717 " python-lsp-server" ,
1818 " cattrs!=23.2.1" ,
1919 " lsprotocol>=2022.0.0a1" ,
Original file line number Diff line number Diff line change @@ -182,6 +182,7 @@ def f():
182182 "--quiet" ,
183183 "--exit-zero" ,
184184 "--output-format=json" ,
185+ "--extension=ipynb:python" ,
185186 "--no-fix" ,
186187 "--force-exclude" ,
187188 f"--stdin-filename={ os .path .join (workspace .root_path , '__init__.py' )} " ,
@@ -243,3 +244,23 @@ def f():
243244 assert diag ["code" ] != "F401"
244245
245246 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