Code action tests fail when global pyproject file exists
rharish101 opened this issue · 3 comments
rharish101 commented
I get the following in test_ruff_code_actions
:
workspace = <pylsp.workspace.Workspace object at 0x7f0938b57130>
def test_ruff_code_actions(workspace):
_, doc = temp_document(codeaction_str, workspace)
diags = ruff_lint.pylsp_lint(workspace, doc)
range_ = cattrs.unstructure(
Range(start=Position(line=0, character=0), end=Position(line=0, character=0))
)
actions = ruff_lint.pylsp_code_actions(
workspace._config, workspace, doc, range=range_, context={"diagnostics": diags}
)
actions = converter.structure(actions, List[CodeAction])
for action in actions:
> assert action.title in codeactions
E AssertionError: assert 'Ruff: Organize imports' in ['Ruff (F401): Remove unused import: `os`', 'Ruff (F401): Disable for this line', 'Ruff (F841): Remove assignment to unused variable `a`', 'Ruff (F841): Disable for this line', 'Ruff: Fix All']
E + where 'Ruff: Organize imports' = CodeAction(title='Ruff: Organize imports', kind=<CodeActionKind.SourceOrganizeImports: 'source.organizeImports'>, diag...range=1:0-2:0, new_text='import os\n\n\n')]}, document_changes=None, change_annotations=None), command=None, data=None).title
tests/test_code_actions.py:76: AssertionError
jhossbach commented
Very odd, can you make sure that everything is up-to-date? Did you clone the repo locally and made any changes?
the Organize imports
action should only happen if I001
is violated which does not happen in the codeaction_str
.
rharish101 commented
Ah, found it, it was due to my global Ruff config. Sorry for the confusion!
jhossbach commented
Reopening to prevent this from happening