Skip to content

Ruff 0.10 #16600

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

Merged
merged 43 commits into from
Mar 13, 2025
Merged

Ruff 0.10 #16600

merged 43 commits into from
Mar 13, 2025

Conversation

MichaReiser
Copy link
Member

@MichaReiser MichaReiser commented Mar 10, 2025

Summary

Release branch for Ruff 0.10

Recoded rules

Deprecated rules

Rule changes

Rule Stabilizations

New or improved fixes

Deferred Stabilizations

TODOs

  • Drop empty first commit
  • Merge with rebase-merge (don't squash merge!!!!)

Copy link
Contributor

github-actions bot commented Mar 10, 2025

ruff-ecosystem results

Linter (stable)

ℹ️ ecosystem check detected linter changes. (+1552 -309 violations, +0 -0 fixes in 33 projects; 22 projects unchanged)

DisnakeDev/disnake (+17 -0 violations, +0 -0 fixes)

+ disnake/abc.py:1242:25: TC006 [*] Add quotes to type expression in `typing.cast()`
+ disnake/abc.py:298:25: TC006 [*] Add quotes to type expression in `typing.cast()`
+ disnake/components.py:766:27: TC006 [*] Add quotes to type expression in `typing.cast()`
+ disnake/ext/commands/base_core.py:211:43: TC006 [*] Add quotes to type expression in `typing.cast()`
+ disnake/ext/commands/cog.py:177:21: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]`
+ disnake/ext/commands/cog.py:179:21: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]`
+ disnake/ext/commands/cog.py:181:21: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]`
+ disnake/ext/commands/core.py:1938:19: TC006 [*] Add quotes to type expression in `typing.cast()`
+ disnake/ext/commands/core.py:1968:19: TC006 [*] Add quotes to type expression in `typing.cast()`
... 6 additional changes omitted for rule TC006
+ disnake/ext/commands/flag_converter.py:314:28: C420 [*] Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead
... 7 additional changes omitted for project

RasaHQ/rasa (+3 -0 violations, +0 -0 fixes)

+ rasa/core/migrate.py:134:9: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]`
+ rasa/nlu/classifiers/diet_classifier.py:781:13: RUF051 [*] Use `pop` instead of `key in dict` followed by `del dict[key]`
+ rasa/shared/core/training_data/loading.py:86:15: RUF046 Value being cast to `int` is already an integer

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

- src/snowflake/cli/_plugins/cortex/types.py:1:1: A005 Module `types` shadows a Python standard-library module
- src/snowflake/cli/_plugins/notebook/types.py:1:1: A005 Module `types` shadows a Python standard-library module
- src/snowflake/cli/api/console/abc.py:1:1: A005 Module `abc` shadows a Python standard-library module
- src/snowflake/cli/api/console/enum.py:1:1: A005 Module `enum` shadows a Python standard-library module
- src/snowflake/cli/api/errno.py:1:1: A005 Module `errno` shadows a Python standard-library module
- src/snowflake/cli/api/output/types.py:1:1: A005 Module `types` shadows a Python standard-library module
- src/snowflake/cli/api/utils/types.py:1:1: A005 Module `types` shadows a Python standard-library module

PlasmaPy/PlasmaPy (+1 -0 violations, +0 -0 fixes)

+ src/plasmapy/particles/ionization_state_collection.py:692:40: C420 [*] Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead

apache/airflow (+249 -74 violations, +0 -0 fixes)

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

+ airflow/api_fastapi/auth/managers/simple/simple_auth_manager.py:260:47: PLW1508 Invalid type for environment variable default; expected `str` or `None`
- airflow/api_fastapi/common/types.py:1:1: A005 Module `types` shadows a Python standard-library module
+ airflow/api_fastapi/core_api/app.py:59:43: PLW1508 Invalid type for environment variable default; expected `str` or `None`
+ airflow/api_fastapi/core_api/app.py:94:29: TC006 [*] Add quotes to type expression in `typing.cast()`
+ airflow/api_fastapi/core_api/routes/public/dag_report.py:54:26: TC006 [*] Add quotes to type expression in `typing.cast()`
+ airflow/api_fastapi/core_api/routes/public/dag_run.py:269:33: TC006 [*] Add quotes to type expression in `typing.cast()`
+ airflow/api_fastapi/core_api/routes/public/plugins.py:44:22: TC006 [*] Add quotes to type expression in `typing.cast()`
+ airflow/api_fastapi/core_api/routes/public/task_instances.py:310:29: TC006 [*] Add quotes to type expression in `typing.cast()`
+ airflow/api_fastapi/core_api/routes/public/tasks.py:60:20: TC006 [*] Add quotes to type expression in `typing.cast()`
... 165 additional changes omitted for rule TC006
+ airflow/api_fastapi/core_api/services/ui/dependencies.py:39:32: C420 [*] Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead
... 313 additional changes omitted for project

apache/superset (+171 -59 violations, +0 -0 fixes)

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

- superset/advanced_data_type/types.py:1:1: A005 Module `types` shadows a Python standard-library module
- superset/async_events/async_query_manager.py:269:12: UP038 Use `X | Y` in `isinstance` call instead of `(X, Y)`
+ superset/charts/api.py:601:22: TC006 [*] Add quotes to type expression in `typing.cast()`
+ superset/charts/api.py:735:22: TC006 [*] Add quotes to type expression in `typing.cast()`
- superset/cli/main.py:55:12: UP038 Use `X | Y` in `isinstance` call instead of `(X, Y)`
- superset/commands/dashboard/copy.py:1:1: A005 Module `copy` shadows a Python standard-library module
+ superset/commands/dashboard/filter_state/create.py:39:22: TC006 [*] Add quotes to type expression in `typing.cast()`
+ superset/commands/dashboard/filter_state/update.py:36:22: TC006 [*] Add quotes to type expression in `typing.cast()`
+ superset/commands/database/tables.py:145:28: TC006 [*] Add quotes to type expression in `typing.cast()`
- superset/commands/dataset/importers/v1/utils.py:212:12: UP038 Use `X | Y` in `isinstance` call instead of `(X, Y)`
... 220 additional changes omitted for project

aws/aws-sam-cli (+13 -1 violations, +0 -0 fixes)

+ samcli/local/docker/container.py:42:93: PLW1508 Invalid type for environment variable default; expected `str` or `None`
+ samcli/local/lambdafn/remote_files.py:33:93: PLW1508 Invalid type for environment variable default; expected `str` or `None`
+ tests/integration/buildcmd/test_build_terraform_applications.py:177:69: PLW1508 Invalid type for environment variable default; expected `str` or `None`
+ tests/integration/package/package_integ_base.py:51:77: PLW1508 Invalid type for environment variable default; expected `str` or `None`
+ tests/integration/package/package_integ_base.py:55:78: PLW1508 Invalid type for environment variable default; expected `str` or `None`
+ tests/integration/publish/publish_app_integ_base.py:22:75: PLW1508 Invalid type for environment variable default; expected `str` or `None`
... 7 additional changes omitted for rule PLW1508
- tests/integration/publish/publish_app_integ_base.py:60:16: PLR1714 Consider merging multiple comparisons: `f.suffix in (".yaml", ".json")`. Use a `set` if the elements are hashable.
+ tests/integration/publish/publish_app_integ_base.py:60:16: PLR1714 Consider merging multiple comparisons: `f.suffix in {".yaml", ".json"}`.
... 6 additional changes omitted for project

binary-husky/gpt_academic (+53 -50 violations, +0 -0 fixes)

- check_proxy.py:161:14: UP015 [*] Unnecessary mode argument
+ check_proxy.py:161:32: UP015 [*] Unnecessary mode argument
- check_proxy.py:191:14: UP015 [*] Unnecessary mode argument
+ check_proxy.py:191:32: UP015 [*] Unnecessary mode argument
- crazy_functions/Conversation_To_File.py:73:14: UP015 [*] Unnecessary mode argument
+ crazy_functions/Conversation_To_File.py:73:30: UP015 [*] Unnecessary mode argument
... 87 additional changes omitted for rule UP015
+ crazy_functions/pdf_fns/parse_pdf.py:117:21: RUF046 Value being cast to `int` is already an integer
+ multi_language.py:262:21: C420 [*] Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead
+ request_llms/bridge_skylark2.py:9:5: SIM103 Return the condition `YUNQUE_SECRET_KEY != ''` directly
- request_llms/bridge_skylark2.py:9:5: SIM103 Return the condition `not YUNQUE_SECRET_KEY == ''` directly
... 93 additional changes omitted for project

bokeh/bokeh (+94 -21 violations, +0 -0 fixes)

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

- examples/interaction/widgets/fileinput.py:1:1: A005 Module `fileinput` shadows a Python standard-library module
+ examples/server/app/simple_hdf5/main.py:19:28: PTH208 Use `pathlib.Path.iterdir()` instead.
+ examples/server/app/spectrogram/main.py:107:13: RUF046 Value being cast to `int` is already an integer
+ scripts/hooks/install.py:5:20: SIM905 [*] Consider using a list literal instead of `str.split`
+ scripts/hooks/uninstall.py:5:20: SIM905 [*] Consider using a list literal instead of `str.split`
+ scripts/milestone.py:33:9: LOG015 `debug()` call on root logger
+ scripts/milestone.py:41:9: LOG015 `debug()` call on root logger
+ scripts/sri.py:20:11: SIM905 [*] Consider using a list literal instead of `str.split`
- src/bokeh/application/handlers/code.py:1:1: A005 Module `code` shadows a Python standard-library module
+ src/bokeh/colors/color.py:338:60: RUF046 Value being cast to `int` is already an integer
... 105 additional changes omitted for project

docker/docker-py (+1 -0 violations, +0 -0 fixes)

+ docker/types/containers.py:725:22: C420 [*] Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead

freedomofpress/securedrop (+33 -0 violations, +0 -0 fixes)

+ admin/tests/test_integration.py:542:27: SIM905 [*] Consider using a list literal instead of `str.split`
+ admin/tests/test_integration.py:547:27: SIM905 [*] Consider using a list literal instead of `str.split`
+ admin/tests/test_integration.py:642:27: SIM905 [*] Consider using a list literal instead of `str.split`
+ admin/tests/test_integration.py:643:27: SIM905 [*] Consider using a list literal instead of `str.split`
+ admin/tests/test_integration.py:646:27: SIM905 [*] Consider using a list literal instead of `str.split`
+ admin/tests/test_integration.py:675:27: SIM905 [*] Consider using a list literal instead of `str.split`
... 7 additional changes omitted for rule SIM905
+ securedrop/journalist_app/account.py:100:20: S704 Unsafe use of `markupsafe.Markup` detected
+ securedrop/journalist_app/account.py:87:20: S704 Unsafe use of `markupsafe.Markup` detected
+ securedrop/journalist_app/admin.py:224:32: S704 Unsafe use of `markupsafe.Markup` detected
+ securedrop/journalist_app/admin.py:279:20: S704 Unsafe use of `markupsafe.Markup` detected
... 23 additional changes omitted for project

... Truncated remaining completed project reports due to GitHub comment length restrictions

Changes by rule (25 rules affected)

code total + violation - violation + fix - fix
TC006 839 839 0 0 0
LOG015 287 287 0 0 0
UP015 110 55 55 0 0
A005 103 0 103 0 0
PLR1714 62 31 31 0 0
PTH208 59 59 0 0 0
C420 57 57 0 0 0
F405 48 0 48 0 0
PLW1508 46 46 0 0 0
UP038 39 0 39 0 0
SIM905 36 36 0 0 0
S704 30 30 0 0 0
PLC1802 29 29 0 0 0
SIM103 26 13 13 0 0
PYI019 19 19 0 0 0
RUF051 18 18 0 0 0
RUF046 16 16 0 0 0
DTZ901 11 11 0 0 0
F811 9 0 9 0 0
F403 9 0 9 0 0
RUF040 3 3 0 0 0
RUF041 2 2 0 0 0
TC004 1 1 0 0 0
S320 1 0 1 0 0
RUF100 1 0 1 0 0

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+30 -115 violations, +0 -0 fixes in 5 projects; 50 projects unchanged)

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

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

- providers/amazon/src/airflow/providers/amazon/aws/hooks/base_aws.py:395:15: S320 Using `lxml` to parse untrusted data is known to be vulnerable to XML attacks
- providers/fab/src/airflow/providers/fab/auth_manager/security_manager/override.py:2344:19: RUF035 Unsafe use of `markupsafe.Markup` detected
+ providers/fab/src/airflow/providers/fab/auth_manager/security_manager/override.py:2344:19: S704 Unsafe use of `markupsafe.Markup` detected

apache/superset (+7 -46 violations, +0 -0 fixes)

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

- superset/async_events/async_query_manager.py:269:12: UP038 Use `X | Y` in `isinstance` call instead of `(X, Y)`
- superset/cli/main.py:55:12: UP038 Use `X | Y` in `isinstance` call instead of `(X, Y)`
- superset/commands/dataset/importers/v1/utils.py:212:12: UP038 Use `X | Y` in `isinstance` call instead of `(X, Y)`
- superset/connectors/sqla/models.py:1308:16: RUF035 Unsafe use of `markupsafe.Markup` detected
+ superset/connectors/sqla/models.py:1308:16: S704 Unsafe use of `markupsafe.Markup` detected
- superset/connectors/sqla/models.py:529:17: UP038 Use `X | Y` in `isinstance` call instead of `(X, Y)`
- superset/connectors/sqla/models.py:562:12: UP038 Use `X | Y` in `isinstance` call instead of `(X, Y)`
- superset/connectors/sqla/models.py:566:35: UP038 Use `X | Y` in `isinstance` call instead of `(X, Y)`
- superset/connectors/sqla/models.py:568:37: UP038 Use `X | Y` in `isinstance` call instead of `(X, Y)`
... 33 additional changes omitted for rule UP038
- superset/models/dashboard.py:225:16: RUF035 Unsafe use of `markupsafe.Markup` detected
+ superset/models/dashboard.py:225:16: S704 Unsafe use of `markupsafe.Markup` detected
- superset/models/helpers.py:538:16: RUF035 Unsafe use of `markupsafe.Markup` detected
+ superset/models/helpers.py:538:16: S704 Unsafe use of `markupsafe.Markup` detected
- superset/models/helpers.py:567:16: RUF035 Unsafe use of `markupsafe.Markup` detected
+ superset/models/helpers.py:567:16: S704 Unsafe use of `markupsafe.Markup` detected
- superset/models/slice.py:338:16: RUF035 Unsafe use of `markupsafe.Markup` detected
+ superset/models/slice.py:338:16: S704 Unsafe use of `markupsafe.Markup` detected
- superset/models/sql_lab.py:445:16: RUF035 Unsafe use of `markupsafe.Markup` detected
... 35 additional changes omitted for project

freedomofpress/securedrop (+21 -0 violations, +0 -0 fixes)

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

+ securedrop/journalist_app/account.py:100:20: S704 Unsafe use of `markupsafe.Markup` detected
+ securedrop/journalist_app/account.py:87:20: S704 Unsafe use of `markupsafe.Markup` detected
+ securedrop/journalist_app/admin.py:224:32: S704 Unsafe use of `markupsafe.Markup` detected
+ securedrop/journalist_app/admin.py:279:20: S704 Unsafe use of `markupsafe.Markup` detected
+ securedrop/journalist_app/admin.py:295:20: S704 Unsafe use of `markupsafe.Markup` detected
+ securedrop/journalist_app/col.py:103:17: S704 Unsafe use of `markupsafe.Markup` detected
+ securedrop/journalist_app/col.py:75:13: S704 Unsafe use of `markupsafe.Markup` detected
+ securedrop/journalist_app/main.py:169:17: S704 Unsafe use of `markupsafe.Markup` detected
+ securedrop/journalist_app/main.py:192:21: S704 Unsafe use of `markupsafe.Markup` detected
+ securedrop/journalist_app/main.py:203:21: S704 Unsafe use of `markupsafe.Markup` detected
... 11 additional changes omitted for project

qdrant/qdrant-client (+0 -66 violations, +0 -0 fixes)

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

- qdrant_client/http/api/aliases_api.py:52:54: F405 `AsyncApiClient` may be undefined, or defined from star imports
- qdrant_client/http/api/aliases_api.py:5:27: F811 Redefinition of unused `BaseModel` from line 4
- qdrant_client/http/api/aliases_api.py:7:1: F403 `from qdrant_client.http.models import *` used; unable to detect undefined names
- qdrant_client/http/api/beta_api.py:51:54: F405 `AsyncApiClient` may be undefined, or defined from star imports
- qdrant_client/http/api/beta_api.py:5:27: F811 Redefinition of unused `BaseModel` from line 4
- qdrant_client/http/api/beta_api.py:7:1: F403 `from qdrant_client.http.models import *` used; unable to detect undefined names
- qdrant_client/http/api/collections_api.py:52:54: F405 `AsyncApiClient` may be undefined, or defined from star imports
- qdrant_client/http/api/collections_api.py:5:27: F811 Redefinition of unused `BaseModel` from line 4
- qdrant_client/http/api/collections_api.py:7:1: F403 `from qdrant_client.http.models import *` used; unable to detect undefined names
- qdrant_client/http/api/distributed_api.py:52:54: F405 `AsyncApiClient` may be undefined, or defined from star imports
- qdrant_client/http/api/distributed_api.py:5:27: F811 Redefinition of unused `BaseModel` from line 4
- qdrant_client/http/api/distributed_api.py:7:1: F403 `from qdrant_client.http.models import *` used; unable to detect undefined names
- qdrant_client/http/api/indexes_api.py:126:19: F405 `WriteOrdering` may be undefined, or defined from star imports
- qdrant_client/http/api/indexes_api.py:144:19: F405 `WriteOrdering` may be undefined, or defined from star imports
- qdrant_client/http/api/indexes_api.py:162:19: F405 `WriteOrdering` may be undefined, or defined from star imports
- qdrant_client/http/api/indexes_api.py:180:19: F405 `WriteOrdering` may be undefined, or defined from star imports
... 41 additional changes omitted for rule F405
- qdrant_client/http/api/indexes_api.py:5:27: F811 Redefinition of unused `BaseModel` from line 4
- qdrant_client/http/api/indexes_api.py:7:1: F403 `from qdrant_client.http.models import *` used; unable to detect undefined names
- qdrant_client/http/api/points_api.py:5:27: F811 Redefinition of unused `BaseModel` from line 4
- qdrant_client/http/api/points_api.py:7:1: F403 `from qdrant_client.http.models import *` used; unable to detect undefined names
- qdrant_client/http/api/search_api.py:5:27: F811 Redefinition of unused `BaseModel` from line 4
- qdrant_client/http/api/search_api.py:7:1: F403 `from qdrant_client.http.models import *` used; unable to detect undefined names
... 44 additional changes omitted for project

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

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

- zerver/views/documentation.py:292:35: RUF035 Unsafe use of `markupsafe.Markup` detected
+ zerver/views/documentation.py:292:35: S704 Unsafe use of `markupsafe.Markup` detected

Changes by rule (7 rules affected)

code total + violation - violation + fix - fix
F405 48 0 48 0 0
UP038 39 0 39 0 0
S704 30 30 0 0 0
RUF035 9 0 9 0 0
F811 9 0 9 0 0
F403 9 0 9 0 0
S320 1 0 1 0 0

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

@MichaReiser MichaReiser added this to the v0.10 milestone Mar 11, 2025
@AlexWaygood AlexWaygood self-requested a review as a code owner March 11, 2025 16:05
ntBre and others added 24 commits March 13, 2025 13:51
Summary
--

Stabilizes RUF048 and moves its test to the right place. The docs look
good.

Test Plan
--

0 closed or open issues. There was 1 [PR] related to an extension to the
rule, but it was closed without comment.

[PR]: #14701
Summary
--

Stabilizes LOG015. The tests and docs looked good.

Test Plan
--

1 closed documentation issue from 4 days after the rule was added, but
no other issues or PRs.
…`) (#16655)

Summary
--

Stabilizes B911. Tests and docs looked good.

Test Plan
--

0 issues or PRs, open or closed
Summary
--

Stabilizes RUF051. The tests and docs looked good.

Test Plan
--

1 closed documentation issue from 4 days after the rule was added and 1
typo fix from the same day it was added, but no other issues or PRs.
## Summary

Follow-up to #16659.

This change adds tests for these three cases, which are (also) not
covered by existing tests:

* `# noqa: A` (lone incomplete code)
* `# noqa: A123, B` (complete codes, last one incomplete)
* `# noqa: A123B` (squashed codes, last one incomplete)
…10`) (#16656)

Summary
--

Stabilizes PTH210. Tests and docs looked good.

Test Plan
--

Mentioned in 1 open issue around Python 3.14 support (`"."` becomes a
valid suffix in 3.14). Otherwise no issues or PRs since 2024-12-12, 6
days after the rule was added.
Summary
--

Stabilizes RUF041. The tests are already in the right place, and the
docs look good.

Test Plan
--

0 issues, 1 [PR] fixing nested literals and unions the day after the
rule was added. No changes since then

I wonder if the fix in that PR could be relevant for
#16639, where I noticed a
potential issue with `Union`. It could be unrelated, though.

[PR]: #14641
## Summary

Follow-up to #16677.

This change converts all unit tests (69 of them) in `noqa.rs` to use
inline snapshots instead. It extends the file by more than 1000 lines,
but the tests are now much easier to read and reason about.

## Test Plan

`cargo insta test`.
Summary
--

Stabilizes DTZ901, renames the rule function to match the rule name,
removes the `preview_rules` test, and handles some nits in the docs
(mention `min` first to match the rule name too).

Test Plan
--

1 closed issue on 2024-11-12, 4 days after the rule was added. No issues
since
Summary
--

Stabilizes S704, which is also being recoded from RUF035 in 0.10.

Test Plan
--
Existing tests with `PreviewMode` removed from the settings.

There was one issue closed on 2024-12-20 calling the rule noisy and
asking for a config option, but the option was added and then there were
no more issues or PRs.
…6637)

Summary
--

Stabilizes TC006. The test was already in the right place.

Test Plan
--

No open issues or PRs. The last related [issue] was closed on
2025-02-09.

[issue]: #16037
## Summary

This PR deprecates UP038. Using PEP 604 syntax in `isinstance` and
`issubclass` calls isn't a recommended pattern (or community agreed best
practice)
and it negatively impacts performance. 

Resolves #7871

## Test Plan

I tested that selecting `UP038` results in a warning in no-preview mode
and an error in preview mode
…PT031`) (#16678)

## Summary

This PR stabilizes the behavior change introduced in
#15542 to allow
for statements with an empty body in `pytest.raises` and `pytest.warns`
with statements.

This raised an error before but is now allowed:

```py
with pytest.raises(KeyError, match='unknown'):
    async for _ in gpt.generate(gpt_request):
        pass
```

The same applies to 

```py
with pytest.raises(KeyError, match='unknown'):
    async for _ in gpt.generate(gpt_request):
        ...
```


There have been now new issues or PRs related to PT012 or PT031 since
this behavior change was introduced in ruff 0.9.3 (January 23rd).
…LW1508`) (#16674)

## Summary
This PR stabilizes the new behavior introduced in
#14512 to also detect defalut
value arguemnts to `os.environ.get` that have an invalid type (not
`str`).
There's an upstream issue for this behavior change
pylint-dev/pylint#10092 that was accepted and
a PR, but it hasn't been merged yet.

This behavior change was first shipped with Ruff 0.8.1 (Nov 22). 

There has only be one PR since the new behavior was introduced but it
was unrelated to the scope increase
(#14841).
## Summary

This PR stabilizes the preview behavior introduced in
#15905

The behavior change is that the rule now also recognizes `type(expr) is
type(None)` comparisons where `expr` isn't a name expression.
For example, the rule now detects `type(a.b) is type(None)` and suggests
rewriting the comparison to `a.b is None`.

The new behavior was introduced with Ruff 0.9.5 (6th of February), about
a month ago. There are no open issues or PRs related to this rule (or
behavior change).
…nvalid-argument-name`) (#16667)

## Summary

This PR stabilizes the preview behavior for `invalid-argument-name`
(`N803`)
to ignore argument names of functions decorated with `typing.override`
because
these methods are *out of the authors* control. 

This behavior was introduced in
#15954
and released as part of Ruff 0.9.5 (6th of February). 

There have been no new issues or PRs since this behavior change
(preview) was introduced.
## Summary

This PR stabilizes the preview behavior introduced in
#15719 to recognize all symbols
named `TYPE_CHECKING` as type-checking
checks in `if TYPE_CHECKING` conditions. This ensures compatibility with
mypy and pyright.

This PR also stabilizes the new behavior that removes `if 0:` and `if
False` to be no longer considered type checking blocks.
Since then, this syntax has been removed from the typing spec and was
only used for Python modules that don't have a `typing` module
([comment](#15719 (comment))).

The preview behavior was first released with Ruff 0.9.5 (6th of
February), which was about a month ago. There are no open issues or PRs
for the changed behavior


## Test Plan

The snapshots for `SIM108` change because `SIM108` ignored type checking
blocks but it can no
simplify `if 0` or `if False` blocks again because they're no longer
considered type checking blocks.

The changes in the `TC005` snapshot or only due to that `if 0` and `if
False` are no longer recognized as type checking blocks

<!-- How was it tested? -->
…P015`) (#16672)

## Summary

This PR stabilizes the behavior change introduced in
#15872

The diagnostic range is now the range of the redundant `mode` argument
where it previously was the range of the entire `open` call:

Before:

```
UP015.py:2:1: UP015 [*] Unnecessary mode argument
  |
1 | open("foo", "U")
2 | open("foo", "Ur")
  | ^^^^^^^^^^^^^^^^^ UP015
3 | open("foo", "Ub")
4 | open("foo", "rUb")
  |
  = help: Remove mode argument
```


Now:

```
UP015.py:2:13: UP015 [*] Unnecessary mode argument
  |
1 | open("foo", "U")
2 | open("foo", "Ur")
  |             ^^^^ UP015
3 | open("foo", "Ub")
4 | open("foo", "rUb")
  |
  = help: Remove mode argument
```

This is a breaking change because it may require moving a `noqa` comment
onto a different line, e.g if you have

```py
open(
    "foo",
    "Ur",
) # noqa: UP015
```

Needs to be rewritten to 

```py
open(
    "foo",
    "Ur", # noqa: UP015
)
```

There have been now new issues or PRs since the new preview behavior was
implemented. It first was released as part of Ruff 0.9.5 on the 5th of
Feb (a little more than a month ago)

## Test Plan

I reviewed the snapshot tests
## Summary

This PR stabilizes the fixes improvements made in
#15562 (released with ruff 0.9.3
in mid January).

There's no open issue or PR related to the changed fix behavior.

This is not a breaking change. The fix was only gated behind preview to
get some more test coverage before releasing.
…6680)

## Summary
Deprecate `S320` because defusedxml has deprecated there `lxml` module
and `lxml` has been hardened since.

flake8-bandit has removed their implementation as well
(PyCQA/bandit#1212).

Addresses #13707


## Test Plan

I verified that selecting `S320` prints a warning and fails if the
preview mode is enabled.
…#16682)

## Summary

This PR stabilizes the fix for `PYI018` introduced in
#15999 (first released with Ruff
0.9.5 early February)

There are no known issues with the fix or open PRs.
…method-argument` and not `invalid-first-argument-name-for-class-method` (`PLW0211`/`N804`) (#16676)

## Summary

This PR stabilizes the behavior changes introduced by
#13305 that were gated behind
preview.
The change is that `__new__` methods are now no longer flagged by
`invalid-first-argument-name-for-class-method` (`N804`) but instead by
`bad-staticmethod-argument` (`PLW0211`)

> __new__ methods are technically static methods, with cls as their
first argument. However, Ruff currently classifies them as classmethod,
which causes two issues:

## Test Plan

There have been no new issues or PRs related to `N804` or `PLW0211`
since the behavior change was released in Ruff 0.9.7 (about 3 weeks
ago).
This is a somewhat recent change but I don't think it's necessary to
leave this in preview for another 2 months. The main reason why it was
in preview
is that it is breaking, not because it is a risky change.
…when all elements are hashable (`PLR1714`) (#16685)

## Summary

This PR promotes the fix improvements for `PLR1714` that were introduced
in #14372 to stable.

The improvement is that the fix now proposes to use a set if all
elements are hashable:

```
foo == "bar" or foo == "baz" or foo == "qux"
```

Gets fixed to 

```py
foo in {"bar", "baz", "qux"}
```

where it previously always got fixed to a tuple.

The new fix was first released in ruff 0.8.0 (Nov last year). This is
not a breaking change. The change was preview gated only to get some
extra test coverage.


There are no open issues or PRs related to this changed fix behavior.
## Summary
This PR stabilizes the behavior introduced in
#15985

The new behavior improves the inference of `str.strip` calls:

* before: The rule only considered calls on string or byte literals
(`"abcd".strip`)
* now: The rule also catches calls to `strip` on object where the type
is known to be a `str` or `bytes` (e.g. `a = "abc"; a.strip("//")`)


The new behavior shipped as part of Ruff 0.9.6 on the 10th of Feb which
is a little more than a month ago.
There have been now new issues or PRs related to the new behavior.
@MichaReiser MichaReiser removed the do-not-merge Do not merge this pull request label Mar 13, 2025
@MichaReiser MichaReiser merged commit d8159e8 into main Mar 13, 2025
26 checks passed
@MichaReiser MichaReiser deleted the micha/ruff-0.10 branch March 13, 2025 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Breaking API change release Related to the release process
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants