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

[refurb] Check for subclasses includes subscript expressions (FURB189) #16155

Conversation

vladNed
Copy link
Contributor

@vladNed vladNed commented Feb 14, 2025

Summary

Added checks for subscript expressions on builtin classes as in FURB189.
The object is changed to use the collections objects and the types from the subscript are kept.

Resolves #16130

Note: Added some comments in the code explaining why

Test Plan

  • Added a subscript dict and list class to the test file.
  • Tested locally to check that the symbols are changed and the types are kept.
  • No modifications changed on optional str values.

Copy link
Contributor

github-actions bot commented Feb 14, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+8 -0 violations, +0 -0 fixes in 6 projects; 49 projects unchanged)

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

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

+ dev/breeze/src/airflow_breeze/utils/selective_checks.py:136:20: FURB189 Subclassing `dict` can be error prone, use `collections.UserDict` instead

apache/superset (+1 -0 violations, +0 -0 fixes)

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

+ superset/db_engine_specs/trino.py:407:30: FURB189 Subclassing `dict` can be error prone, use `collections.UserDict` instead

bokeh/bokeh (+2 -0 violations, +0 -0 fixes)

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

+ src/bokeh/util/compiler.py:73:16: FURB189 Subclassing `dict` can be error prone, use `collections.UserDict` instead
+ src/typings/bs4.pyi:12:17: FURB189 Subclassing `list` can be error prone, use `collections.UserList` instead

langchain-ai/langchain (+1 -0 violations, +0 -0 fixes)

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

+ libs/core/langchain_core/runnables/utils.py:465:19: FURB189 Subclassing `dict` can be error prone, use `collections.UserDict` instead

reflex-dev/reflex (+2 -0 violations, +0 -0 fixes)

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

+ tests/units/utils/test_types.py:50:18: FURB189 Subclassing `dict` can be error prone, use `collections.UserDict` instead
+ tests/units/vars/test_base.py:9:18: FURB189 Subclassing `dict` can be error prone, use `collections.UserDict` instead

python-trio/trio (+1 -0 violations, +0 -0 fixes)

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

+ src/trio/_core/_instrumentation.py:24:19: FURB189 Subclassing `dict` can be error prone, use `collections.UserDict` instead

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
FURB189 8 8 0 0 0

Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

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

Nice. I've a small nit comment but that otherwise looks good to go.

@MichaReiser MichaReiser added rule Implementing or modifying a lint rule preview Related to preview mode features labels Feb 14, 2025
@vladNed vladNed requested a review from MichaReiser February 14, 2025 18:14
@MichaReiser MichaReiser merged commit 2197128 into astral-sh:main Feb 14, 2025
21 checks passed
@vladNed vladNed deleted the bugfix/furb-189-rule-not-applied-when-type-args-provided branch February 15, 2025 03:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preview Related to preview mode features rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(🐞) subclass-builtin (FURB189) doesn't apply when type arguments are supplied
2 participants