Skip to content

Fix infinite hang during lint when code contains some imports#996

Merged
chvp merged 2 commits intomainfrom
fix/re-import-lint-infinite-hang
Apr 13, 2026
Merged

Fix infinite hang during lint when code contains some imports#996
chvp merged 2 commits intomainfrom
fix/re-import-lint-infinite-hang

Conversation

@chvp
Copy link
Copy Markdown
Member

@chvp chvp commented Apr 13, 2026

For some reason, the astroid version we use hangs indefinitely when linting import re or usage of pandas dataframes. This is because it goes into the modules and gets into some infinite recursion there.

This is a band-aid fix since updating astroid would involve updating pylint, and we use some APIs that were removed in newer versions. I will create an issue for updating pylint separately (which will mention to try removing this band-aid).

Fixes #950.

@chvp chvp requested a review from Copilot April 13, 2026 08:01
@chvp chvp self-assigned this Apr 13, 2026
@chvp chvp added the bug Something isn't working label Apr 13, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses an infinite hang during Python linting (PyLint/astroid in the Pyodide worker) when user code contains import re.

Changes:

  • Add Vitest coverage for executing Python code that imports re.
  • Add a linting regression test to ensure lintSource() completes for import re.
  • Introduce an astroid monkeypatch in the Python worker linting layer to short-circuit module loading for re and related modules.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
test/tests/state/Runner.test.ts Adds runtime and lint regression tests around import re.
src/backend/workers/python/papyros/linting.py Monkeypatches astroid module loading to avoid the hang when linting code that imports re.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/backend/workers/python/papyros/linting.py Outdated
Comment thread src/backend/workers/python/papyros/linting.py Outdated
Comment thread src/backend/workers/python/papyros/linting.py Outdated
Comment thread test/__tests__/state/Runner.test.ts
@chvp chvp requested a review from TomNaessens April 13, 2026 08:13
@chvp chvp marked this pull request as ready for review April 13, 2026 08:13
@chvp chvp mentioned this pull request Apr 13, 2026
@chvp chvp changed the title Fix infinite hang during lint when code contains re import Fix infinite hang during lint when code contains some imports Apr 13, 2026
@chvp
Copy link
Copy Markdown
Member Author

chvp commented Apr 13, 2026

I expanded the scope of this PR to disable the loading of all modules by astroid, since we were having issues with pandas dataframes as well.

Copy link
Copy Markdown
Member

@bmesuere bmesuere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@chvp chvp merged commit 004093a into main Apr 13, 2026
6 checks passed
@chvp chvp deleted the fix/re-import-lint-infinite-hang branch April 13, 2026 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

import re fails

3 participants