Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect automagic-like assignments in notebooks #9653

Merged
merged 1 commit into from Jan 29, 2024
Merged

Conversation

charliermarsh
Copy link
Member

@charliermarsh charliermarsh commented Jan 26, 2024

Summary

Given a statement like colors = 6, we currently treat the cell as an automagic (since colors is an automagic) -- i.e., we assume it's equivalent to %colors = 6. This PR adds some additional detection whereby if the statement is an assignment, we avoid treating it as such. I audited the list of automagics, and I believe this is safe for all of them.

Closes #8526.

Closes #9648.

Test Plan

cargo test

Copy link
Contributor

github-actions bot commented Jan 26, 2024

ruff-ecosystem results

Linter (stable)

ℹ️ ecosystem check detected linter changes. (+0 -3 violations, +0 -0 fixes in 1 projects; 42 projects unchanged)

mlflow/mlflow (+0 -3 violations, +0 -0 fixes)

- examples/llms/RAG/question-generation-retrieval-evaluation.ipynb:cell 14:1:1: F821 Undefined name `df`
- examples/llms/RAG/question-generation-retrieval-evaluation.ipynb:cell 4:14:8: F401 [*] `requests` imported but unused
- examples/llms/RAG/question-generation-retrieval-evaluation.ipynb:cell 4:16:17: F401 [*] `bs4.BeautifulSoup` imported but unused

Changes by rule (2 rules affected)

code total + violation - violation + fix - fix
F401 2 0 2 0 0
F821 1 0 1 0 0

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+0 -3 violations, +0 -0 fixes in 1 projects; 42 projects unchanged)

mlflow/mlflow (+0 -3 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --preview

- examples/llms/RAG/question-generation-retrieval-evaluation.ipynb:cell 14:1:1: F821 Undefined name `df`
- examples/llms/RAG/question-generation-retrieval-evaluation.ipynb:cell 4:14:8: F401 [*] `requests` imported but unused
- examples/llms/RAG/question-generation-retrieval-evaluation.ipynb:cell 4:16:17: F401 [*] `bs4.BeautifulSoup` imported but unused

Changes by rule (2 rules affected)

code total + violation - violation + fix - fix
F401 2 0 2 0 0
F821 1 0 1 0 0

@charliermarsh
Copy link
Member Author

Ecosystem checks are correct (i.e., they were false positives before the change).

crates/ruff_notebook/src/cell.rs Outdated Show resolved Hide resolved
@charliermarsh charliermarsh enabled auto-merge (squash) January 29, 2024 12:50
@charliermarsh charliermarsh merged commit bea8f2e into main Jan 29, 2024
15 checks passed
@charliermarsh charliermarsh deleted the charlie/auto branch January 29, 2024 12:55
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
2 participants