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

Ruff 0.8 #14383

Merged
merged 21 commits into from
Nov 20, 2024
Merged

Ruff 0.8 #14383

merged 21 commits into from
Nov 20, 2024

Conversation

@AlexWaygood AlexWaygood added breaking Breaking API change release Related to the release process labels Nov 16, 2024
@AlexWaygood AlexWaygood changed the title [ruff 0.8] Remove deprecated rule UP027 (#14382) Ruff 0.8 (#14382) Nov 16, 2024
@AlexWaygood AlexWaygood changed the title Ruff 0.8 (#14382) Ruff 0.8 Nov 16, 2024
@AlexWaygood AlexWaygood added the do-not-merge Do not merge this pull request label Nov 16, 2024
Copy link
Contributor

github-actions bot commented Nov 16, 2024

ruff-ecosystem results

Linter (stable)

ℹ️ ecosystem check detected linter changes. (+1526 -711 violations, +0 -0 fixes in 30 projects; 24 projects unchanged)

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

+ disnake/abc.py:205:17: RUF023 [*] `_Overwrites.__slots__` is not sorted
+ disnake/abc.py:49:11: RUF022 [*] `__all__` is not sorted
+ disnake/activity.py:13:11: RUF022 [*] `__all__` is not sorted
+ disnake/activity.py:289:17: RUF023 [*] `Activity.__slots__` is not sorted
+ disnake/activity.py:530:17: RUF023 [*] `Streaming.__slots__` is not sorted
+ disnake/activity.py:619:17: RUF023 [*] `Spotify.__slots__` is not sorted
+ disnake/activity.py:803:17: RUF023 [*] `CustomActivity.__slots__` is not sorted
+ disnake/app_commands.py:1017:17: RUF023 [*] `ApplicationCommandPermissions.__slots__` is not sorted
... 113 additional changes omitted for rule RUF023
+ disnake/app_commands.py:49:11: RUF022 [*] `__all__` is not sorted
+ disnake/appinfo.py:23:11: RUF022 [*] `__all__` is not sorted
... 163 additional changes omitted for project

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

+ rasa/cli/utils.py:74:27: RUF021 [*] Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear
+ rasa/core/processor.py:587:17: RUF021 [*] Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear
+ rasa/shared/core/training_data/structures.py:619:17: RUF021 [*] Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear
+ rasa/shared/core/training_data/structures.py:621:20: RUF021 [*] Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear
+ rasa/utils/train_utils.py:534:9: RUF021 [*] Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear
+ rasa/utils/train_utils.py:536:12: RUF021 [*] Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear
... 1 additional changes omitted for rule RUF021
+ stubs/aio_pika/__init__.pyi:23:11: RUF022 [*] `__all__` is not sorted
+ stubs/sanic.pyi:11:11: RUF022 [*] `__all__` is not sorted

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

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

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

+ src/plasmapy/particles/_special_particles.py:260:5: PLC0206 Extracting value from dictionary without calling `.items()`
+ src/plasmapy/particles/decorators.py:677:9: PLC0206 Extracting value from dictionary without calling `.items()`
+ src/plasmapy/particles/ionization_state_collection.py:479:13: PLC0206 Extracting value from dictionary without calling `.items()`
+ src/plasmapy/plasma/grids.py:769:9: PLC0206 Extracting value from dictionary without calling `.items()`

apache/airflow (+176 -115 violations, +0 -0 fixes)

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

+ airflow/__init__.py:63:11: RUF022 [*] `__all__` is not sorted
+ airflow/__main__.py:25:22: TC003 Move standard library import `argparse.Namespace` into a type-checking block
- airflow/__main__.py:25:22: TCH003 Move standard library import `argparse.Namespace` into a type-checking block
+ airflow/api_connexion/schemas/asset_schema.py:19:22: TC003 Move standard library import `datetime.datetime` into a type-checking block
- airflow/api_connexion/schemas/asset_schema.py:19:22: TCH003 Move standard library import `datetime.datetime` into a type-checking block
+ airflow/api_fastapi/common/parameters.py:21:22: TC003 Move standard library import `datetime.datetime` into a type-checking block
- airflow/api_fastapi/common/parameters.py:21:22: TCH003 Move standard library import `datetime.datetime` into a type-checking block
+ airflow/api_fastapi/common/router.py:20:18: TC003 Move standard library import `enum.Enum` into a type-checking block
- airflow/api_fastapi/common/router.py:20:18: TCH003 Move standard library import `enum.Enum` into a type-checking block
+ airflow/api_fastapi/common/types.py:19:22: TC003 Move standard library import `datetime.timedelta` into a type-checking block
... 281 additional changes omitted for project

apache/superset (+330 -321 violations, +0 -0 fixes)

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

+ RELEASING/changelog.py:227:9: PLC0206 Extracting value from dictionary without calling `.items()`
+ superset/advanced_data_type/api.py:28:47: TC001 Move application import `superset.advanced_data_type.types.AdvancedDataTypeResponse` into a type-checking block
- superset/advanced_data_type/api.py:28:47: TCH001 Move application import `superset.advanced_data_type.types.AdvancedDataTypeResponse` into a type-checking block
+ superset/async_events/async_query_manager.py:26:41: TC002 Move third-party import `flask_caching.backends.base.BaseCache` into a type-checking block
- superset/async_events/async_query_manager.py:26:41: TCH002 Move third-party import `flask_caching.backends.base.BaseCache` into a type-checking block
+ superset/charts/data/api.py:43:45: TC001 Move application import `superset.connectors.sqla.models.BaseDatasource` into a type-checking block
- superset/charts/data/api.py:43:45: TCH001 Move application import `superset.connectors.sqla.models.BaseDatasource` into a type-checking block
+ superset/charts/data/api.py:47:37: TC001 Move application import `superset.models.sql_lab.Query` into a type-checking block
- superset/charts/data/api.py:47:37: TCH001 Move application import `superset.models.sql_lab.Query` into a type-checking block
+ superset/cli/test_db.py:45:43: TC001 Move application import `superset.db_engine_specs.base.BaseEngineSpec` into a type-checking block
- superset/cli/test_db.py:45:43: TCH001 Move application import `superset.db_engine_specs.base.BaseEngineSpec` into a type-checking block
+ superset/commands/annotation_layer/annotation/create.py:18:22: TC003 Move standard library import `datetime.datetime` into a type-checking block
- superset/commands/annotation_layer/annotation/create.py:18:22: TCH003 Move standard library import `datetime.datetime` into a type-checking block
+ superset/commands/annotation_layer/annotation/create.py:23:25: TC002 Move third-party import `marshmallow.ValidationError` into a type-checking block
... 637 additional changes omitted for project

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

+ tests/integration/pipeline/test_bootstrap_command.py:229:9: PLC0206 Extracting value from dictionary without calling `.items()`

bokeh/bokeh (+305 -233 violations, +0 -0 fixes)

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

+ examples/models/widgets.py:84:37: UP031 Use format specifiers instead of percent format
+ examples/models/widgets.py:86:37: UP031 Use format specifiers instead of percent format
+ release/build.py:18:21: TC001 Move application import `.config.Config` into a type-checking block
- release/build.py:18:21: TCH001 Move application import `.config.Config` into a type-checking block
+ release/build.py:19:21: TC001 Move application import `.system.System` into a type-checking block
- release/build.py:19:21: TCH001 Move application import `.system.System` into a type-checking block
+ release/checks.py:19:21: TC001 Move application import `.config.Config` into a type-checking block
- release/checks.py:19:21: TCH001 Move application import `.config.Config` into a type-checking block
+ release/checks.py:20:23: TC001 Move application import `.pipeline.StepType` into a type-checking block
- release/checks.py:20:23: TCH001 Move application import `.pipeline.StepType` into a type-checking block
+ release/checks.py:21:21: TC001 Move application import `.system.System` into a type-checking block
- release/checks.py:21:21: TCH001 Move application import `.system.System` into a type-checking block
... 526 additional changes omitted for project

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

+ molecule/testinfra/ossec/test_journalist_mail.py:14:45: RUF100 [*] Unused `noqa` directive (non-enabled: `PT004`)
+ securedrop/source_app/utils.py:86:17: UP031 Use format specifiers instead of percent format

ibis-project/ibis (+86 -0 violations, +0 -0 fixes)

+ ibis/backends/impala/tests/test_exprs.py:135:29: UP031 Use format specifiers instead of percent format
+ ibis/backends/impala/tests/test_exprs.py:421:29: UP031 Use format specifiers instead of percent format
+ ibis/backends/impala/tests/test_exprs.py:477:26: UP031 Use format specifiers instead of percent format
+ ibis/backends/impala/tests/test_exprs.py:514:29: UP031 Use format specifiers instead of percent format
+ ibis/backends/impala/udf.py:24:11: RUF022 [*] `__all__` is not sorted
+ ibis/backends/oracle/tests/test_client.py:3:36: RUF101 [*] `TCH003` is a redirect to `TC003`
+ ibis/backends/polars/rewrites.py:10:50: RUF101 [*] `TCH001` is a redirect to `TC001`
+ ibis/backends/sql/compilers/__init__.py:3:11: RUF022 [*] `__all__` is not sorted
+ ibis/backends/sql/compilers/base.py:178:17: RUF023 [*] `FuncGen.__slots__` is not sorted
+ ibis/backends/sql/compilers/base.py:83:21: RUF023 [*] `_Accessor.__slots__` is not sorted
... 76 additional changes omitted for project

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

+ libs/core/langchain_core/runnables/config.py:114:38: B039 Do not use mutable data structures for `ContextVar` defaults

latchbio/latch (+13 -6 violations, +0 -0 fixes)

+ src/latch/functions/operators.py:183:9: PLC0206 Extracting value from dictionary without calling `.items()`
+ src/latch/functions/operators.py:37:5: PLC0206 Extracting value from dictionary without calling `.items()`
+ src/latch/functions/operators.py:48:5: PLC0206 Extracting value from dictionary without calling `.items()`
+ src/latch/functions/operators.py:59:5: PLC0206 Extracting value from dictionary without calling `.items()`
+ src/latch/functions/operators.py:68:5: PLC0206 Extracting value from dictionary without calling `.items()`
+ src/latch/functions/operators.py:73:5: PLC0206 Extracting value from dictionary without calling `.items()`
... 1 additional changes omitted for rule PLC0206
+ src/latch/ldata/_transfer/upload.py:10:38: TC003 Move standard library import `multiprocessing.managers.DictProxy` into a type-checking block
- src/latch/ldata/_transfer/upload.py:10:38: TCH003 Move standard library import `multiprocessing.managers.DictProxy` into a type-checking block
+ src/latch/ldata/_transfer/upload.py:10:49: TC003 Move standard library import `multiprocessing.managers.ListProxy` into a type-checking block
- src/latch/ldata/_transfer/upload.py:10:49: TCH003 Move standard library import `multiprocessing.managers.ListProxy` into a type-checking block
... 9 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
TCH001 354 0 354 0 0
TC001 352 352 0 0 0
TC003 202 202 0 0 0
TCH003 202 0 202 0 0
RUF023 167 167 0 0 0
TC002 147 147 0 0 0
TCH002 147 0 147 0 0
RUF022 146 146 0 0 0
UP006 145 145 0 0 0
UP035 71 71 0 0 0
A004 66 66 0 0 0
RUF021 64 64 0 0 0
UP031 62 62 0 0 0
RUF101 46 46 0 0 0
PLC0206 43 43 0 0 0
PYI063 5 5 0 0 0
B039 4 4 0 0 0
PT004 3 0 3 0 0
RUF200 2 2 0 0 0
D212 2 1 1 0 0
TC005 2 2 0 0 0
TCH005 2 0 2 0 0
RUF100 1 1 0 0 0
A001 1 0 1 0 0
TCH004 1 0 1 0 0

Linter (preview)

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

apache/airflow (+125 -119 violations, +0 -0 fixes)

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

+ airflow/__main__.py:25:22: TC003 Move standard library import `argparse.Namespace` into a type-checking block
- airflow/__main__.py:25:22: TCH003 Move standard library import `argparse.Namespace` into a type-checking block
+ airflow/api_connexion/schemas/asset_schema.py:19:22: TC003 Move standard library import `datetime.datetime` into a type-checking block
- airflow/api_connexion/schemas/asset_schema.py:19:22: TCH003 Move standard library import `datetime.datetime` into a type-checking block
+ airflow/api_fastapi/common/parameters.py:21:22: TC003 Move standard library import `datetime.datetime` into a type-checking block
- airflow/api_fastapi/common/parameters.py:21:22: TCH003 Move standard library import `datetime.datetime` into a type-checking block
+ airflow/api_fastapi/common/router.py:20:18: TC003 Move standard library import `enum.Enum` into a type-checking block
- airflow/api_fastapi/common/router.py:20:18: TCH003 Move standard library import `enum.Enum` into a type-checking block
+ airflow/api_fastapi/common/types.py:19:22: TC003 Move standard library import `datetime.timedelta` into a type-checking block
- airflow/api_fastapi/common/types.py:19:22: TCH003 Move standard library import `datetime.timedelta` into a type-checking block
... 234 additional changes omitted for project

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

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

+ superset/advanced_data_type/api.py:28:47: TC001 Move application import `superset.advanced_data_type.types.AdvancedDataTypeResponse` into a type-checking block
- superset/advanced_data_type/api.py:28:47: TCH001 Move application import `superset.advanced_data_type.types.AdvancedDataTypeResponse` into a type-checking block
+ superset/async_events/async_query_manager.py:26:41: TC002 Move third-party import `flask_caching.backends.base.BaseCache` into a type-checking block
- superset/async_events/async_query_manager.py:26:41: TCH002 Move third-party import `flask_caching.backends.base.BaseCache` into a type-checking block
+ superset/charts/data/api.py:43:45: TC001 Move application import `superset.connectors.sqla.models.BaseDatasource` into a type-checking block
- superset/charts/data/api.py:43:45: TCH001 Move application import `superset.connectors.sqla.models.BaseDatasource` into a type-checking block
+ superset/charts/data/api.py:47:37: TC001 Move application import `superset.models.sql_lab.Query` into a type-checking block
- superset/charts/data/api.py:47:37: TCH001 Move application import `superset.models.sql_lab.Query` into a type-checking block
+ superset/cli/test_db.py:45:43: TC001 Move application import `superset.db_engine_specs.base.BaseEngineSpec` into a type-checking block
- superset/cli/test_db.py:45:43: TCH001 Move application import `superset.db_engine_specs.base.BaseEngineSpec` into a type-checking block
+ superset/commands/annotation_layer/annotation/create.py:18:22: TC003 Move standard library import `datetime.datetime` into a type-checking block
- superset/commands/annotation_layer/annotation/create.py:18:22: TCH003 Move standard library import `datetime.datetime` into a type-checking block
+ superset/commands/annotation_layer/annotation/create.py:23:25: TC002 Move third-party import `marshmallow.ValidationError` into a type-checking block
- superset/commands/annotation_layer/annotation/create.py:23:25: TCH002 Move third-party import `marshmallow.ValidationError` into a type-checking block
+ superset/commands/annotation_layer/annotation/delete.py:27:41: TC001 Move application import `superset.models.annotations.Annotation` into a type-checking block
- superset/commands/annotation_layer/annotation/delete.py:27:41: TCH001 Move application import `superset.models.annotations.Annotation` into a type-checking block
+ superset/commands/annotation_layer/annotation/update.py:18:22: TC003 Move standard library import `datetime.datetime` into a type-checking block
- superset/commands/annotation_layer/annotation/update.py:18:22: TCH003 Move standard library import `datetime.datetime` into a type-checking block
... 624 additional changes omitted for project

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

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

+ release/build.py:18:21: TC001 Move application import `.config.Config` into a type-checking block
- release/build.py:18:21: TCH001 Move application import `.config.Config` into a type-checking block
+ release/build.py:19:21: TC001 Move application import `.system.System` into a type-checking block
- release/build.py:19:21: TCH001 Move application import `.system.System` into a type-checking block
+ release/checks.py:19:21: TC001 Move application import `.config.Config` into a type-checking block
- release/checks.py:19:21: TCH001 Move application import `.config.Config` into a type-checking block
+ release/checks.py:20:23: TC001 Move application import `.pipeline.StepType` into a type-checking block
- release/checks.py:20:23: TCH001 Move application import `.pipeline.StepType` into a type-checking block
+ release/checks.py:21:21: TC001 Move application import `.system.System` into a type-checking block
- release/checks.py:21:21: TCH001 Move application import `.system.System` into a type-checking block
+ release/credentials.py:24:21: TC001 Move application import `.config.Config` into a type-checking block
... 189 additional changes omitted for rule TC001
- release/credentials.py:24:21: TCH001 Move application import `.config.Config` into a type-checking block
... 189 additional changes omitted for rule TCH001
+ src/bokeh/application/handlers/code.py:41:19: TC003 Move standard library import `types.ModuleType` into a type-checking block
... 451 additional changes omitted for project

ibis-project/ibis (+42 -0 violations, +0 -0 fixes)

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

+ ibis/backends/oracle/tests/test_client.py:3:36: RUF101 [*] `TCH003` is a redirect to `TC003`
+ ibis/backends/polars/rewrites.py:10:50: RUF101 [*] `TCH001` is a redirect to `TC001`
+ ibis/backends/sql/rewrites.py:17:57: RUF101 [*] `TCH001` is a redirect to `TC001`
+ ibis/backends/sql/rewrites.py:21:50: RUF101 [*] `TCH001` is a redirect to `TC001`
+ ibis/common/grounds.py:29:57: RUF101 [*] `TCH001` is a redirect to `TC001`
+ ibis/common/selectors.py:8:50: RUF101 [*] `TCH001` is a redirect to `TC001`
+ ibis/config.py:3:47: RUF101 [*] `TCH003` is a redirect to `TC003`
+ ibis/expr/builders.py:16:53: RUF101 [*] `TCH001` is a redirect to `TC001`
+ ibis/expr/builders.py:17:50: RUF101 [*] `TCH001` is a redirect to `TC001`
+ ibis/expr/datatypes/tests/test_core.py:3:26: RUF101 [*] `TCH003` is a redirect to `TC003`
... 32 additional changes omitted for project

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

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

+ src/latch/ldata/_transfer/upload.py:10:38: TC003 Move standard library import `multiprocessing.managers.DictProxy` into a type-checking block
- src/latch/ldata/_transfer/upload.py:10:38: TCH003 Move standard library import `multiprocessing.managers.DictProxy` into a type-checking block
+ src/latch/ldata/_transfer/upload.py:10:49: TC003 Move standard library import `multiprocessing.managers.ListProxy` into a type-checking block
- src/latch/ldata/_transfer/upload.py:10:49: TCH003 Move standard library import `multiprocessing.managers.ListProxy` into a type-checking block
+ src/latch/ldata/_transfer/upload.py:12:19: TC003 Move standard library import `queue.Queue` into a type-checking block
- src/latch/ldata/_transfer/upload.py:12:19: TCH003 Move standard library import `queue.Queue` into a type-checking block
+ src/latch/registry/record.py:18:49: TC001 Move application import `latch.registry.upstream_types.types.DBType` into a type-checking block
- src/latch/registry/record.py:18:49: TCH001 Move application import `latch.registry.upstream_types.types.DBType` into a type-checking block
+ src/latch_cli/services/register/utils.py:5:8: TC003 Move standard library import `io` into a type-checking block
- src/latch_cli/services/register/utils.py:5:8: TCH003 Move standard library import `io` into a type-checking block
... 2 additional changes omitted for project

lnbits/lnbits (+216 -0 violations, +0 -0 fixes)

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

+ lnbits/app.py:257:6: UP006 Use `list` instead of `List` for type annotation
+ lnbits/app.py:9:1: UP035 `typing.List` is deprecated, use `list` instead
+ lnbits/commands.py:235:23: UP006 Use `list` instead of `List` for type annotation
+ lnbits/commands.py:465:6: UP006 Use `tuple` instead of `Tuple` for type annotation
+ lnbits/commands.py:494:6: UP006 Use `tuple` instead of `Tuple` for type annotation
+ lnbits/commands.py:6:1: UP035 `typing.List` is deprecated, use `list` instead
+ lnbits/commands.py:6:1: UP035 `typing.Tuple` is deprecated, use `tuple` instead
+ lnbits/core/crud.py:1018:6: UP006 Use `list` instead of `List` for type annotation
+ lnbits/core/crud.py:1235:43: UP006 Use `list` instead of `List` for type annotation
... 140 additional changes omitted for rule UP006
+ lnbits/core/crud.py:4:1: UP035 `typing.Dict` is deprecated, use `dict` instead
... 206 additional changes omitted for project

pandas-dev/pandas (+3 -4 violations, +0 -0 fixes)

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

- pandas/_typing.py:276:20: PYI063 Use PEP 570 syntax for positional-only arguments
+ pandas/_typing.py:276:20: PYI063 Use PEP 570 syntax for positional-only parameters
- pandas/_typing.py:291:20: PYI063 Use PEP 570 syntax for positional-only arguments
+ pandas/_typing.py:291:20: PYI063 Use PEP 570 syntax for positional-only parameters
- pandas/_typing.py:297:21: PYI063 Use PEP 570 syntax for positional-only arguments
+ pandas/_typing.py:297:21: PYI063 Use PEP 570 syntax for positional-only parameters
... 1 additional changes omitted for rule PYI063
- pandas/core/dtypes/dtypes.py:76:23: TCH004 Move import `pyarrow` out of type-checking block. Import is used for more than type hinting.

pypa/cibuildwheel (+2 -2 violations, +0 -0 fixes)

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

+ bin/bump_version.py:20:4: PYI066 Put branches for newer Python versions first when branching on `sys.version_info` comparisons
- bin/bump_version.py:20:4: PYI066 Use `>=` when using `if`-`else` with `sys.version_info` comparisons
+ cibuildwheel/_compat/typing.py:5:4: PYI066 Put branches for newer Python versions first when branching on `sys.version_info` comparisons
- cibuildwheel/_compat/typing.py:5:4: PYI066 Use `>=` when using `if`-`else` with `sys.version_info` comparisons

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

Changes by rule (15 rules affected)

code total + violation - violation + fix - fix
TC001 352 352 0 0 0
TCH001 352 0 352 0 0
TC003 202 202 0 0 0
TCH003 202 0 202 0 0
TC002 147 147 0 0 0
TCH002 147 0 147 0 0
UP006 145 145 0 0 0
UP035 71 71 0 0 0
PYI066 62 31 31 0 0
RUF101 46 46 0 0 0
PYI063 10 5 5 0 0
RUF200 2 2 0 0 0
TC005 2 2 0 0 0
TCH005 2 0 2 0 0
TCH004 1 0 1 0 0

Formatter (stable)

ℹ️ ecosystem check detected format changes. (+111 -85 lines in 16 files in 4 projects; 50 projects unchanged)

aws/aws-sam-cli (+34 -30 lines across 4 files)

tests/integration/pipeline/test_init_command.py~L98

 
         self.assertEqual(init_process_execute.process.returncode, 0)
 
-        with open(EXPECTED_JENKINS_FILE_PATH, "r") as expected, open(
-            os.path.join(".aws-sam", "pipeline", "generated-files", "Jenkinsfile"), "r"
-        ) as output:
+        with (
+            open(EXPECTED_JENKINS_FILE_PATH, "r") as expected,
+            open(os.path.join(".aws-sam", "pipeline", "generated-files", "Jenkinsfile"), "r") as output,
+        ):
             self.assertEqual(expected.read(), output.read())
 
         # also check the Jenkinsfile is not overridden

tests/unit/commands/samconfig/test_samconfig.py~L1066

         }
 
         # NOTE: Because we don't load the full Click BaseCommand here, this is mounted as top-level command
-        with samconfig_parameters(
-            ["start-lambda"], self.scratch_dir, **config_values
-        ) as config_path, tempfile.NamedTemporaryFile() as key_file, tempfile.NamedTemporaryFile() as cert_file:
+        with (
+            samconfig_parameters(["start-lambda"], self.scratch_dir, **config_values) as config_path,
+            tempfile.NamedTemporaryFile() as key_file,
+            tempfile.NamedTemporaryFile() as cert_file,
+        ):
             from samcli.commands.local.start_lambda.cli import cli
 
             LOG.debug(Path(config_path).read_text())

tests/unit/commands/samconfig/test_samconfig.py~L1171

         }
 
         # NOTE: Because we don't load the full Click BaseCommand here, this is mounted as top-level command
-        with samconfig_parameters(
-            ["start-lambda"], self.scratch_dir, **config_values
-        ) as config_path, tempfile.NamedTemporaryFile() as key_file, tempfile.NamedTemporaryFile() as cert_file:
+        with (
+            samconfig_parameters(["start-lambda"], self.scratch_dir, **config_values) as config_path,
+            tempfile.NamedTemporaryFile() as key_file,
+            tempfile.NamedTemporaryFile() as cert_file,
+        ):
             from samcli.commands.local.start_lambda.cli import cli
 
             LOG.debug(Path(config_path).read_text())

tests/unit/lib/build_module/test_build_strategy.py~L747

     def test_will_call_incremental_build_strategy(self, mocked_read, mocked_write, runtime):
         build_definition = FunctionBuildDefinition(runtime, "codeuri", None, "package_type", X86_64, {}, "handler")
         self.build_graph.put_function_build_definition(build_definition, Mock(full_path="function_full_path"))
-        with patch.object(
-            self.build_strategy, "_incremental_build_strategy"
-        ) as patched_incremental_build_strategy, patch.object(
-            self.build_strategy, "_cached_build_strategy"
-        ) as patched_cached_build_strategy:
+        with (
+            patch.object(self.build_strategy, "_incremental_build_strategy") as patched_incremental_build_strategy,
+            patch.object(self.build_strategy, "_cached_build_strategy") as patched_cached_build_strategy,
+        ):
             self.build_strategy.build()
 
             patched_incremental_build_strategy.build_single_function_definition.assert_called_with(build_definition)

tests/unit/lib/build_module/test_build_strategy.py~L767

     def test_will_call_cached_build_strategy(self, mocked_read, mocked_write, runtime):
         build_definition = FunctionBuildDefinition(runtime, "codeuri", None, "package_type", X86_64, {}, "handler")
         self.build_graph.put_function_build_definition(build_definition, Mock(full_path="function_full_path"))
-        with patch.object(
-            self.build_strategy, "_incremental_build_strategy"
-        ) as patched_incremental_build_strategy, patch.object(
-            self.build_strategy, "_cached_build_strategy"
-        ) as patched_cached_build_strategy:
+        with (
+            patch.object(self.build_strategy, "_incremental_build_strategy") as patched_incremental_build_strategy,
+            patch.object(self.build_strategy, "_cached_build_strategy") as patched_cached_build_strategy,
+        ):
             self.build_strategy.build()
 
             patched_cached_build_strategy.build_single_function_definition.assert_called_with(build_definition)

tests/unit/lib/build_module/test_build_strategy.py~L841

 
         build_definition = FunctionBuildDefinition(runtime, "codeuri", None, "package_type", X86_64, {}, "handler")
         self.build_graph.put_function_build_definition(build_definition, Mock(full_path="function_full_path"))
-        with patch.object(
-            build_strategy, "_incremental_build_strategy"
-        ) as patched_incremental_build_strategy, patch.object(
-            build_strategy, "_cached_build_strategy"
-        ) as patched_cached_build_strategy:
+        with (
+            patch.object(build_strategy, "_incremental_build_strategy") as patched_incremental_build_strategy,
+            patch.object(build_strategy, "_cached_build_strategy") as patched_cached_build_strategy,
+        ):
             build_strategy.build()
 
             if not use_container:

tests/unit/lib/remote_invoke/test_remote_invoke_executors.py~L79

         given_output_format = "text"
         test_execution_info = RemoteInvokeExecutionInfo(given_payload, None, given_parameters, given_output_format)
 
-        with patch.object(self.boto_action_executor, "_execute_action") as patched_execute_action, patch.object(
-            self.boto_action_executor, "_execute_action_file"
-        ) as patched_execute_action_file:
+        with (
+            patch.object(self.boto_action_executor, "_execute_action") as patched_execute_action,
+            patch.object(self.boto_action_executor, "_execute_action_file") as patched_execute_action_file,
+        ):
             given_result = Mock()
             patched_execute_action.return_value = given_result
 

tests/unit/lib/remote_invoke/test_remote_invoke_executors.py~L96

         given_output_format = "json"
         test_execution_info = RemoteInvokeExecutionInfo(None, given_payload_file, given_parameters, given_output_format)
 
-        with patch.object(self.boto_action_executor, "_execute_action") as patched_execute_action, patch.object(
-            self.boto_action_executor, "_execute_action_file"
-        ) as patched_execute_action_file:
+        with (
+            patch.object(self.boto_action_executor, "_execute_action") as patched_execute_action,
+            patch.object(self.boto_action_executor, "_execute_action_file") as patched_execute_action_file,
+        ):
             given_result = Mock()
             patched_execute_action_file.return_value = given_result
 

langchain-ai/langchain (+32 -23 lines across 5 files)

libs/community/tests/unit_tests/document_loaders/test_mongodb.py~L50

     mock_collection.find = mock_find
     mock_collection.count_documents = mock_count_documents
 
-    with patch(
-        "motor.motor_asyncio.AsyncIOMotorClient", return_value=MagicMock()
-    ), patch(
-        "langchain_community.document_loaders.mongodb.MongodbLoader.aload",
-        new=mock_async_load,
+    with (
+        patch("motor.motor_asyncio.AsyncIOMotorClient", return_value=MagicMock()),
+        patch(
+            "langchain_community.document_loaders.mongodb.MongodbLoader.aload",
+            new=mock_async_load,
+        ),
     ):
         loader = MongodbLoader(
             "mongodb://localhost:27017",

libs/community/tests/unit_tests/tools/audio/test_tools.py~L44

 def test_huggingface_tts_run_with_requests_mock() -> None:
     os.environ["HUGGINGFACE_API_KEY"] = "foo"
 
-    with tempfile.TemporaryDirectory() as tmp_dir, patch(
-        "uuid.uuid4"
-    ) as mock_uuid, patch("requests.post") as mock_inference, patch(
-        "builtins.open", mock_open()
-    ) as mock_file:
+    with (
+        tempfile.TemporaryDirectory() as tmp_dir,
+        patch("uuid.uuid4") as mock_uuid,
+        patch("requests.post") as mock_inference,
+        patch("builtins.open", mock_open()) as mock_file,
+    ):
         input_query = "Dummy input"
 
         mock_uuid_value = uuid.UUID("00000000-0000-0000-0000-000000000000")

libs/community/tests/unit_tests/vectorstores/test_azure_search.py~L220

     ]
     ids_provided = [i.metadata.get("id") for i in documents]
 
-    with patch.object(
-        SearchClient, "upload_documents", mock_upload_documents
-    ), patch.object(SearchIndexClient, "get_index", mock_default_index):
+    with (
+        patch.object(SearchClient, "upload_documents", mock_upload_documents),
+        patch.object(SearchIndexClient, "get_index", mock_default_index),
+    ):
         vector_store = create_vector_store()
         ids_used_at_upload = vector_store.add_documents(documents, ids=ids_provided)
         assert len(ids_provided) == len(ids_used_at_upload)

libs/langchain/tests/unit_tests/smith/evaluation/test_runner_utils.py~L316

         proj.id = "123"
         return proj
 
-    with mock.patch.object(
-        Client, "read_dataset", new=mock_read_dataset
-    ), mock.patch.object(Client, "list_examples", new=mock_list_examples), mock.patch(
-        "langchain.smith.evaluation.runner_utils._arun_llm_or_chain",
-        new=mock_arun_chain,
-    ), mock.patch.object(Client, "create_project", new=mock_create_project):
+    with (
+        mock.patch.object(Client, "read_dataset", new=mock_read_dataset),
+        mock.patch.object(Client, "list_examples", new=mock_list_examples),
+        mock.patch(
+            "langchain.smith.evaluation.runner_utils._arun_llm_or_chain",
+            new=mock_arun_chain,
+        ),
+        mock.patch.object(Client, "create_project", new=mock_create_project),
+    ):
         client = Client(api_url="http://localhost:1984", api_key="123")
         chain = mock.MagicMock()
         chain.input_keys = ["foothing"]

libs/partners/huggingface/tests/unit_tests/test_chat_models.py~L231

 
 def test_bind_tools(chat_hugging_face: Any) -> None:
     tools = [MagicMock(spec=BaseTool)]
-    with patch(
-        "langchain_huggingface.chat_models.huggingface.convert_to_openai_tool",
-        side_effect=lambda x: x,
-    ), patch("langchain_core.runnables.base.Runnable.bind") as mock_super_bind:
+    with (
+        patch(
+            "langchain_huggingface.chat_models.huggingface.convert_to_openai_tool",
+            side_effect=lambda x: x,
+        ),
+        patch("langchain_core.runnables.base.Runnable.bind") as mock_super_bind,
+    ):
         chat_hugging_face.bind_tools(tools, tool_choice="auto")
         mock_super_bind.assert_called_once()
         _, kwargs = mock_super_bind.call_args

prefecthq/prefect (+38 -27 lines across 5 files)

src/integrations/prefect-dbt/prefect_dbt/cloud/jobs.py~L752

         run_status = DbtCloudJobRunStatus(run_data.get("status"))
         if run_status == DbtCloudJobRunStatus.SUCCESS:
             try:
-                async with self._dbt_cloud_credentials.get_administrative_client() as client:  # noqa
+                async with (
+                    self._dbt_cloud_credentials.get_administrative_client() as client
+                ):  # noqa
                     response = await client.list_run_artifacts(
                         run_id=self.run_id, step=step
                     )

tests/runner/test_webserver.py~L151

             webserver = await build_server(runner)
             client = TestClient(webserver)
 
-            with mock.patch(
-                "prefect.runner.server.get_client", new=mock_get_client
-            ), mock.patch.object(runner, "execute_in_background"):
+            with (
+                mock.patch("prefect.runner.server.get_client", new=mock_get_client),
+                mock.patch.object(runner, "execute_in_background"),
+            ):
                 with client:
                     response = client.post(f"/deployment/{deployment_id}/run")
                 assert response.status_code == 201, response.json()

tests/server/orchestration/api/test_task_run_subscriptions.py~L326

             )
             await queue.put(task_run)
 
-        with patch("asyncio.sleep", return_value=None), pytest.raises(
-            asyncio.TimeoutError
+        with (
+            patch("asyncio.sleep", return_value=None),
+            pytest.raises(asyncio.TimeoutError),
         ):
             extra_task_run = ServerTaskRun(
                 id=uuid4(),

tests/server/orchestration/api/test_task_run_subscriptions.py~L356

         )
         await queue.retry(task_run)
 
-        with patch("asyncio.sleep", return_value=None), pytest.raises(
-            asyncio.TimeoutError
+        with (
+            patch("asyncio.sleep", return_value=None),
+            pytest.raises(asyncio.TimeoutError),
         ):
             extra_task_run = ServerTaskRun(
                 id=uuid4(),

tests/test_task_worker.py~L106

 async def test_handle_sigterm(mock_create_subscription):
     task_worker = TaskWorker(...)
 
-    with patch("sys.exit") as mock_exit, patch.object(
-        task_worker, "stop", new_callable=AsyncMock
-    ) as mock_stop:
+    with (
+        patch("sys.exit") as mock_exit,
+        patch.object(task_worker, "stop", new_callable=AsyncMock) as mock_stop,
+    ):
         await task_worker.start()
 
         mock_create_subscription.assert_called_once()

tests/test_task_worker.py~L120

 
 
 async def test_task_worker_client_id_is_set():
-    with patch("socket.gethostname", return_value="foo"), patch(
-        "os.getpid", return_value=42
+    with (
+        patch("socket.gethostname", return_value="foo"),
+        patch("os.getpid", return_value=42),
     ):
         task_worker = TaskWorker(...)
         task_worker._client = MagicMock(api_url="http://localhost:4200")

tests/workers/test_base_worker.py~L1985

     ):
         async with WorkerTestImpl(work_pool_name=work_pool.name) as worker:
             await worker.start(run_once=True)
-            with mock.patch(
-                "prefect....*[Comment body truncated]*

@AlexWaygood
Copy link
Member Author

The UP027 removal means that we now error on setuptools's config, but only because they already explicitly ignore UP027, because it was deprecated: https://github.com/pypa/setuptools/blob/540001561bc2c6766940ba5fd6247735c1a3a290/ruff.toml#L40. I think that's fine.

@Skylion007
Copy link
Contributor

Skylion007 commented Nov 17, 2024

Since we are stabilizing things, there seem to be many lower risk FURB rules we could stabilize: https://docs.astral.sh/ruff/rules/#refurb-furb like FURB148, FURB131, FURB145

@AlexWaygood
Copy link
Member Author

Thanks @Skylion007. I'll be spending a bunch of time this week looking through which rules are suitable for stabilisation in this release. I'll make sure to look at those, among many others :-)

@Avasam
Copy link
Contributor

Avasam commented Nov 17, 2024

The UP027 removal means that we now error on setuptools's config, but only because they already explicitly ignore UP027, because it was deprecated: pypa/setuptools@5400015/ruff.toml#L40. I think that's fine.

Btw I got a relevant feature request to make those warnings by default: #13505 (so that configs can work across more versions without failing)

Copy link

codspeed-hq bot commented Nov 18, 2024

CodSpeed Performance Report

Merging #14383 will improve performances by 4.44%

Comparing ruff-0.8 (c702110) with main (a6deca4)

Summary

⚡ 1 improvements
✅ 31 untouched benchmarks

Benchmarks breakdown

Benchmark main ruff-0.8 Change
red_knot_check_file[incremental] 4.2 ms 4 ms +4.44%

@MichaReiser

This comment was marked as outdated.

@AlexWaygood

This comment was marked as outdated.

@MichaReiser

This comment was marked as outdated.

AlexWaygood and others added 12 commits November 20, 2024 10:26
…14401)

This PR stabilizes the unsafe fix for [zip-instead-of-pairwise
(RUF007)](https://docs.astral.sh/ruff/rules/zip-instead-of-pairwise/#zip-instead-of-pairwise-ruf007),
which replaces the use of zip with that of itertools.pairwise and has
been available under preview since version 0.5.7.

There are no open issues regarding RUF007 at the time of this writing.
Co-authored-by: Micha Reiser <micha@reiser.io>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…ANN102 (#14384)

Co-authored-by: Micha Reiser <micha@reiser.io>
…PT005 (#14385)

Co-authored-by: Micha Reiser <micha@reiser.io>
AlexWaygood and others added 6 commits November 20, 2024 10:26
…der-slots` (#14468)

## Summary

These rules were implemented in January, have been very stable, and have
no open issues about them. They were highly requested by the community
prior to being implemented. Let's stabilise them!

## Test Plan

Ecosystem check on this PR.
## Summary

- Expand some docs where they're unclear about the motivation, or assume
some knowledge that hasn't been introduced yet
- Add more links to external docs
- Rename PYI063 from `PrePep570PositionalArgument` to
`Pep484StylePositionalOnlyParameter`
- Rename the file `parenthesize_logical_operators.rs` to
`parenthesize_chained_operators.rs`, since the rule is called
`ParenthesizeChainedOperators`, not `ParenthesizeLogicalOperators`

## Test Plan

`cargo test`
@MichaReiser MichaReiser marked this pull request as ready for review November 20, 2024 12:07
@MichaReiser MichaReiser self-requested a review as a code owner November 20, 2024 12:07
@AlexWaygood AlexWaygood removed the do-not-merge Do not merge this pull request label Nov 20, 2024
@MichaReiser MichaReiser enabled auto-merge (rebase) November 20, 2024 12:09
@MichaReiser MichaReiser merged commit 942d6ee into main Nov 20, 2024
19 checks passed
@MichaReiser MichaReiser deleted the ruff-0.8 branch November 20, 2024 12:11
@Skylion007
Copy link
Contributor

Ah, the FURB rules didn't make it? ;-;

@AlexWaygood
Copy link
Member Author

Ah, the FURB rules didn't make it? ;-;

Not this release, unfortunately. I did look at them, but I'm a little concerned that these rules are quite highly opinionated. I'm not sure all users would agree that the changes they recommend would result in more idiomatic Python; I think they're very subjective.

The long-term answer to this problem is to improve our rule categorisation so that we can clearly signal to users that these are highly opinionated rules and have them disabled by default. Unfortunately I can't tell you when rule recategorisation is likely to happen, however :-(

@Skylion007
Copy link
Contributor

Skylion007 commented Nov 21, 2024

@AlexWaygood I agree with most of the FURB rules being opinionated, but my understanding is that FURB131, FURB132, and FURB145 have performance implications in code which is why I wanted to enable those specifically. FURB148 also just removes an unused variable/functional call, but I can see why that might want to be left in preview because the fixit is more complicated.

@AlexWaygood
Copy link
Member Author

It's possible that some of these might make a tiny difference to performance, but I think it's very unlikely to make a significant difference unless you're in a very hot loop. The recommendations to avoid slicing are also the kind of thing where relative performance of different idioms is likely to change quite a lot between Python releases (especially right now, when there's a lot of work going into Python performance, and when very significant optimisations for slices have just been landed on the CPython main branch).

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.

9 participants