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

Stabilize A004 #14480

Merged
merged 2 commits into from
Nov 20, 2024
Merged

Stabilize A004 #14480

merged 2 commits into from
Nov 20, 2024

Conversation

MichaReiser
Copy link
Member

Summary

Stabilize A004.

Stabilizing A004 requires a breaking change to A001 (see #12546)
Before, A001 used to flag shadowed builtins for import and from ... import statements.
Keep doing so now would overlap with A004. That's why this PR also stabilizes the behavior change to stop flaging import and from ... import builtin shadowing in A001.

Test Plan

I reviewed the test changes and verified that the no-longer flagged violations by A001 are now flagged by A004

@MichaReiser MichaReiser added rule Implementing or modifying a lint rule breaking Breaking API change labels Nov 20, 2024
@MichaReiser MichaReiser added this to the v0.8 milestone Nov 20, 2024
@@ -591,18 +591,7 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) {
if checker.enabled(Rule::NonAsciiImportName) {
pylint::rules::non_ascii_module_import(checker, alias);
}
// TODO(charlie): Remove when stabilizing A004.
Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks @charliermarsh for adding the TODO comments. I would have missed this otherwise!

Copy link
Contributor

github-actions bot commented Nov 20, 2024

ruff-ecosystem results

Linter (stable)

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

Snowflake-Labs/snowcli (+1 -0 violations, +0 -0 fixes)

+ performance_history_analysis.py:24:18: A004 Import `print` is shadowing a Python builtin

apache/airflow (+8 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --no-preview --select ALL

+ airflow/api_internal/internal_api_call.py:115:37: A004 Import `ConnectionError` is shadowing a Python builtin
+ clients/python/test_python_client.py:36:22: A004 Import `print` is shadowing a Python builtin
+ dev/check_files.py:24:18: A004 Import `print` is shadowing a Python builtin
+ providers/src/airflow/providers/cncf/kubernetes/utils/pod_manager.py:39:43: A004 Import `TimeoutError` is shadowing a Python builtin
+ providers/src/airflow/providers/databricks/hooks/databricks_base.py:31:32: A004 Import `TimeoutError` is shadowing a Python builtin
+ providers/tests/databricks/hooks/test_databricks.py:24:32: A004 Import `TimeoutError` is shadowing a Python builtin
+ scripts/ci/pre_commit/check_order_dockerfile_extras.py:28:18: A004 Import `print` is shadowing a Python builtin
+ scripts/ci/pre_commit/check_order_hatch_build.py:28:18: A004 Import `print` is shadowing a Python builtin

bokeh/bokeh (+7 -1 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --no-preview --select ALL

+ src/bokeh/core/validation/check.py:36:20: A004 Import `Warning` is shadowing a Python builtin
+ src/bokeh/core/validation/decorators.py:34:34: A004 Import `Warning` is shadowing a Python builtin
+ src/bokeh/core/validation/warnings.py:37:20: A004 Import `Warning` is shadowing a Python builtin
- src/bokeh/models/callbacks.py:25:42: A001 Variable `any` is shadowing a Python builtin
+ src/bokeh/models/callbacks.py:25:42: A004 Import `any` is shadowing a Python builtin
+ tests/support/plugins/bokeh_server.py:33:33: A004 Import `ConnectionError` is shadowing a Python builtin
+ tests/support/plugins/jupyter_notebook.py:39:33: A004 Import `ConnectionError` is shadowing a Python builtin
... 2 additional changes omitted for rule A004

latchbio/latch (+1 -0 violations, +0 -0 fixes)

+ src/latch_cli/main.py:440:48: A004 Import `exec` is shadowing a Python builtin

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

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --no-preview --select ALL

+ zerver/tests/test_link_embed.py:11:33: A004 Import `ConnectionError` is shadowing a Python builtin
+ zerver/tests/test_push_notifications.py:24:33: A004 Import `ConnectionError` is shadowing a Python builtin
+ zerver/tornado/django_api.py:11:31: A004 Import `ConnectionError` is shadowing a Python builtin

zanieb/huggingface-notebooks (+25 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --no-preview --select A,E703,F704,B015,B018,D100

+ diffusers/SDXL_DreamBooth_LoRA_.ipynb:cell 40:1:29: A004 Import `display` is shadowing a Python builtin
+ diffusers/geodiff_molecule_conformation.ipynb:cell 63:4:34: A004 Import `display` is shadowing a Python builtin
+ examples/accelerate_examples/simple_nlp_example.ipynb:cell 16:4:29: A004 Import `display` is shadowing a Python builtin
+ examples/audio_classification.ipynb:cell 32:2:36: A004 Import `display` is shadowing a Python builtin
+ examples/language_modeling-tf.ipynb:cell 23:4:29: A004 Import `display` is shadowing a Python builtin
+ examples/language_modeling.ipynb:cell 23:4:29: A004 Import `display` is shadowing a Python builtin
+ examples/language_modeling_from_scratch-tf.ipynb:cell 23:4:29: A004 Import `display` is shadowing a Python builtin
+ examples/language_modeling_from_scratch.ipynb:cell 23:4:29: A004 Import `display` is shadowing a Python builtin
+ examples/multi_lingual_speech_recognition.ipynb:cell 25:4:29: A004 Import `display` is shadowing a Python builtin
+ examples/multiple_choice-tf.ipynb:cell 24:4:29: A004 Import `display` is shadowing a Python builtin
+ examples/multiple_choice.ipynb:cell 24:4:29: A004 Import `display` is shadowing a Python builtin
+ examples/question_answering-tf.ipynb:cell 28:4:29: A004 Import `display` is shadowing a Python builtin
+ examples/question_answering.ipynb:cell 28:4:29: A004 Import `display` is shadowing a Python builtin
+ examples/speech_recognition.ipynb:cell 25:4:29: A004 Import `display` is shadowing a Python builtin
+ examples/summarization-tf.ipynb:cell 24:4:29: A004 Import `display` is shadowing a Python builtin
+ examples/summarization.ipynb:cell 24:4:29: A004 Import `display` is shadowing a Python builtin
+ examples/summarization_ort.ipynb:cell 20:4:29: A004 Import `display` is shadowing a Python builtin
+ examples/text_classification-tf.ipynb:cell 27:4:29: A004 Import `display` is shadowing a Python builtin
... 7 additional changes omitted for project

openai/openai-cookbook (+21 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --no-preview --select A,E703,F704,B015,B018,D100

+ examples/Creating_slides_with_Assistants_API_and_DALL-E3.ipynb:cell 3:1:29: A004 Import `display` is shadowing a Python builtin
+ examples/Developing_hallucination_guardrails.ipynb:cell 2:2:29: A004 Import `display` is shadowing a Python builtin
+ examples/Fine_tuning_for_function_calling.ipynb:cell 10:4:29: A004 Import `display` is shadowing a Python builtin
+ examples/GPT_with_vision_for_video_understanding.ipynb:cell 2:1:29: A004 Import `display` is shadowing a Python builtin
+ examples/How_to_call_functions_for_knowledge_retrieval.ipynb:cell 3:10:29: A004 Import `display` is shadowing a Python builtin
+ examples/How_to_combine_GPT4o_with_RAG_Outfit_Assistant.ipynb:cell 5:10:36: A004 Import `display` is shadowing a Python builtin
+ examples/Named_Entity_Recognition_to_enrich_text.ipynb:cell 9:9:29: A004 Import `display` is shadowing a Python builtin
+ examples/Parse_PDF_docs_for_RAG.ipynb:cell 5:20:18: A004 Import `print` is shadowing a Python builtin
+ examples/Question_answering_using_a_search_API.ipynb:cell 3:3:21: A004 Import `display` is shadowing a Python builtin
+ examples/Reproducible_outputs_with_the_seed_parameter.ipynb:cell 6:3:29: A004 Import `display` is shadowing a Python builtin
+ examples/Structured_Outputs_Intro.ipynb:cell 9:1:35: A004 Import `display` is shadowing a Python builtin
+ examples/Tag_caption_images_with_GPT4V.ipynb:cell 4:1:36: A004 Import `display` is shadowing a Python builtin
+ examples/Using_logprobs.ipynb:cell 3:4:29: A004 Import `display` is shadowing a Python builtin
+ examples/batch_processing.ipynb:cell 4:4:36: A004 Import `display` is shadowing a Python builtin
+ examples/evaluation/Getting_Started_with_OpenAI_Evals.ipynb:cell 28:35:33: A004 Import `display` is shadowing a Python builtin
... 6 additional changes omitted for project

Changes by rule (2 rules affected)

code total + violation - violation + fix - fix
A004 66 66 0 0 0
A001 1 0 1 0 0

Linter (preview)

✅ ecosystem check detected no linter changes.

@MichaReiser
Copy link
Member Author

The ecosystem checks look correct to me and they also highlight why it's important that A001 and A004 are different rules. A004 seems slightly more annoying because it requires changes on the user side where A001 prevents naming conflicts on the definition side (which seems preferrable in my view)

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

Thank you!

@MichaReiser MichaReiser merged commit c702110 into ruff-0.8 Nov 20, 2024
20 checks passed
@MichaReiser MichaReiser deleted the stabilize-a004 branch November 20, 2024 12:06
@MichaReiser MichaReiser mentioned this pull request Nov 20, 2024
MichaReiser added a commit that referenced this pull request Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Breaking API change rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants